Page 1 of 1

@#! daylight saving time…

Posted: Tue Mar 31, 2015 9:14 pm
by jihem
I use the date in seconds to compute the number of days between two dates.
And got this problem on a system in Washington DC (03/08/2015, 03/09/2015) and on another in France (03/29/2015, 03/30/2015)…

#! /bin/lc
local tDay
local tFst
-- put the long date into tDay
-- put "03/29/2015" into tDay
put "03/30/2015" into tDay
put "01/01/" into tFst
put word 1 to -1 of item 3 of the long date after tFst
convert tFst to seconds
convert tDay to seconds
put (tDay-tFst)/86400+1

03/29 => 88
03/30 => 88.958333

The number of seconds for a day is 24 (h) x 60 (min) x 60 (s) = 86400.
Where is the missing part? (1-0.958333)*86400 =~ 3600s = 1h
With the daylight saving the 03/08 (in Washington) and the 03/29 (in France) have only 23 hours.

I fix this with :
put trunc((gDay-tFst+3600)/86400+1)

In hope this could help :)

Re: @#! daylight saving time…

Posted: Mon Jun 22, 2015 4:19 am
by sturgis
One thing I do, when the exact hour doesn't matter, is use 12:00 noon of the day in question to generate my seconds.

Code: Select all

put the date && "12:00 PM" into tDay
convert tDay to seconds 
This helps avoid the crankiness caused by daylight savings when calculating days between.