Flex: calculate the clock in 2 times?

I am creating a planning system. The current system is just using excel and they dial in times like 9: 3-5 (value 9:30 am-5pm). I have not configured the format for how this data will still be stored, I think I might have to use military time to be able to calculate the hours, but I would like to avoid this if possible. But basically I need to figure out how to calculate the hours. e.g. 9: 3-5 (7.5 hours). I am open to different ways of storing time. I just need to be able to display it easily so that the user can understand and calculate how many hours it will be.

Any ideas?

Thank!!

+2


source to share


2 answers


A quick dirty ugly solution



public static const millisecondsPerHour:int = 1000 * 60 * 60;

private function getHoursDifference(minDate:Date, maxDate:Date):uint {
  return Math.ceil(( maxDate.getTime() - minDate.getTime()) / millisecondsPerHour);
}

      

+3


source


Okay, it looks like you are talking about changing a schedule or plan that is currently being developed by a person using an Excel spreadsheet and want to "computerize" this process. 1st warning: "Scheduling is not trivial." How you store the time is not that important, but usually some level of granularity is set and the task time is converted to integer multiples of this interval to simplify the scheduling task.

If you want to automate the process, or just check for an error, you need to abstract a little. Basic weekly calendar with start and end times and may need to change information. An exception calendar is a good idea to plan from the start. The exception calendar allows holidays and other exceptions. This will require a table with information on resources and capacity. You will need a table containing all the tasks for scheduling and any dependencies between the tasks. Do you want to consider concurrent requirements? (I need a truck and a driver ...) Would you like to consider periodic resource scheduling? Should you support planning forward or backward? Do you plan to support if scripting? (Then you need a master schedule that is independent of the scheduling schedule.)Do you want to prioritize how tasks will be scheduled? (Much is required depending on the work being done, although it is necessary.) You can very well define a subset of the tasks for the actual planning. Then just create a reporting mechanism to show if the remaining work can fit into the white space on the schedule. (If you can't get the most demanding 10% done in the available time, who cares about the other 90%)(If you can't get the most demanding 10% done in the available time, who cares about the other 90%)(If you can't get the most demanding 10% done in the available time, who cares about the other 90%)



Second warning: "If God had written the timetable, most companies would not have been able to follow it."

0


source







All Articles