The seconds problem - redefined
J. Landman Gay
jacque at hyperactivesw.com
Thu Apr 15 00:26:00 EDT 2004
On 4/14/04 10:39 PM, SimPLsol at aol.com wrote:
> Since I raised this topic I've gotten a LOT of good advice.
> Unfortunately most of it does not address the problem. Apparently I have not defined it
> well, please bear with me and I'll try again:
> Start with a list of events: employee birthdays, anniversaries, start
> dates, order due out dates, raw material due in dates, conferences, training
> sessions, etc. The list is dynamic; new employees are hired, new materials are
> purchased, materials scheduled previously arrive, etc.
> Which events in that list will be happening, by day, for the next x
> days?
> For simplicity assume there are only three items in the event list; the
> first event occurs on April 3rd 2004, the second on April 4th, and the third
> on April 5th.
> Revolution converts each date in the event list to seconds as follows:
> April 3, 2004 - converts to 1080986400 seconds (OK)
> April 4, 2004 - converts to 1081069200 seconds (will be a problem)
> April 5, 2004 - converts to 1081155600 seconds (also a problem,
> because of the 4th)
> Next create a day by day calendar showing events from the event list
> above for each calendar day. Start on April 2nd (1080900000 seconds) and review
> four days, adding 86400 to get the comparison seconds for the next day to be
> reviewed:
> April 2, 2004 = 1080900000 seconds,
> empty (correct, no events in the event list above match this
> date)
> April 3, 2004 = 1080986400 seconds (1080900000 + 86400)
> one event (correct, matches the April 3 seconds from the event
> list above)
> April 4, 2004 = 1081072800 seconds (1080986400 + 86400)
> no match, (wrong, April 4 in the list above is short 3600
> seconds, because April 3 only had 23 hours according to Revolution)
> April 5, 2004 = 1081159200 seconds (1081072800 + 86400)
> no match (wrong, April 5 in the list above is also short 3600
> seconds,
> indeed all dates until the 25 hour day in the autumn will not
> match)
>
> If our review had started on the 4th (after the 23 hour day), all dates
> would have matched correctly (until the 25 hour day in autumn).
>
> Hope that helps. Now back to the original question. Is there a way to
> convert dates to seconds where every day has 86400 seconds?
Maybe I'm still not understanding correctly, but do you have to use
seconds? Why not just convert a date to short date, or dateItems, or any
other date format and compare that?
If you use dateItems, you can add 1 to the day item, reconvert, and get
the correct date. For example, starting on April 2:
put "4/2/04" into theDate
-- scan your event list here, converting each one to short date.
-- compare and extract matches
convert theDate to dateItems
add 1 to item 3 of theDate
convert theDate to short date -- now it says "4/3/04"
-- scan the event list again and extract matches
etc.
If you add 1 to the days item when the date is April 30, the conversion
from dateItems to any other date format will kick it over into May
automatically. It's pretty easy.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list