@#! daylight saving time…

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Posts: 53
Joined: Sun Jul 28, 2013 3:21 pm

@#! daylight saving time…

Post by jihem » Tue Mar 31, 2015 9:14 pm

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 :)

Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1682
Joined: Sat Feb 28, 2009 11:49 pm

Re: @#! daylight saving time…

Post by sturgis » Mon Jun 22, 2015 4:19 am

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.

Post Reply

Return to “Internet”