
Its a parameter that needs to be checked any time a certain function is run. The requirement is that that function can only be run within specific times. (start time and end time) There is no limitation to the day as it is a user invoked function On Thu, May 2, 2013 at 9:58 AM, Adam Nelson <adam@varud.com> wrote:
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
https://twitter.com/varud https://www.linkedin.com/in/adamcnelson
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 = 0600 EndTime = 1800
TimeNow = 0950
An algorithm like
If TimeNow >= StartTime and <= EndTime then allow
would work
However, this will not work if the Start/End time spans across 2 days:
StartTime = 1800 EndTime = 0600
TimeNow = 0550
Using 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