25 hour day

1 view
Skip to first unread message

Bryan Cockerham

unread,
Nov 10, 2009, 9:57:02 AM11/10/09
to nyit-pro...@googlegroups.com

Pretty funny…

 

If you have a loop that starts on day x and ends on day y, and you’re incrementing by 24 hours (86400 seconds), you’ll find that you’ll get 11/01/2009 twice!  The day has 25 hours (Daylight Savings).

 

My quick solution was to add 3 hours to the timestamp on day x.  Then looping through, I still get exactly the same whole days, but +/- 1 hour as the clocks change won’t affect the output.

 

-Bryan

 

 

 

 

 

 

--

about me: http://www.bryancockerham.com

 

Relax.  Don't be so hard on yourself.   You don't have to be perfect...

...you just have to be better than everyone else.

 

Ben Zajac

unread,
Nov 10, 2009, 10:14:44 AM11/10/09
to nyit-pro...@googlegroups.com
If you have a loop that starts on day x and ends on day y, you might want to refactor for optimization. Unless you are trying to brute force crack a time based encryption system...

Bryan Cockerham

unread,
Nov 10, 2009, 10:28:44 AM11/10/09
to nyit-pro...@googlegroups.com

LOL, none of my code runs for days :)

 

I meant something like:

 

for(date=two_months_back; date < today; date+=86400){

                print “today is: “.date(“m-d-Y”, date);

}

 

You’ll get 11-01-2009 twice.

Reply all
Reply to author
Forward
0 new messages