I'm working on a similar project and, if I come up with a valid algorithm, I'll post it.
At a high level, this is how I figure it'll work, based on calculating the total number of seconds between the two dates and times:
- Normalize the fromdate and todate into Base dates (the DATE(B) format). Subtract fromdate from todate to get the total number of days elapsed. For each full day, add 86400 to the total number of seconds elapsed.
- For the fromtime, calculate the number of seconds already used for the day (hours % 3600) + (minutes % 60) + seconds, and subtract that value from 86400, giving the number of seconds left until midnight.
- For the totime, calculate the number of seconds already used for the day (same as above, except don't subtract the value from 86400).
- Total all the values as the total seconds elapsed, then calculate back into days/hours/minutes/seconds.
/* rexx */
date1 = '12 Oct 2006'
time1 = 9
/* use "date2 = DATE()" for current date */
date2 = '13 Oct 2006'
/* use "time2 = time('H')" for current time */
time2 = 11
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.