I would just include date information in the timestamp. Any timestamp you get from a library will already have that information in it anyway.The real question is, why are you doing this yourself. Surely, whatever language you use has a date comparison library and can handle this situation with a simple method. Reinventing the wheel, especially with a domain as intractable as dates and times, is a 'bad' idea.Let us know what you come up with though.Cheers,Adam
On Thu, May 2, 2013 at 8:54 AM, Bwana Lawi <mail2lawi@gmail.com> wrote:Hi guys,Programmers, what algorithm would you use to check that a given time (current timestamp in 24hr) is within a preset start and end times and if so, do specific stuff?Scenario:StartTime = 0600EndTime = 1800TimeNow = 0950An algorithm likeIf TimeNow >= StartTime and <= EndTime then allowwould workHowever, this will not work if the Start/End time spans across 2 days:StartTime = 1800EndTime = 0600TimeNow = 0550Using the logic will fail yet 0550 is logically within the preset timeframe_______________________________________________
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
_______________________________________________
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke