time problems with daylight saving

Sarah Reichelt sarahr at genesearch.com.au
Mon Nov 8 21:36:09 CST 2004

In case anyone else is struggling with a similar problem, here is my 
workaround. I have written a routine which uses the AppleScript "time 
to GMT" to get the time difference, then I use "the internet time" to 
get the current time zone. The difference between these two is the 
daylight savings period. I convert this to seconds and when emailing 
time-stamped reports to another time zone, I apply the difference. I 
haven't finished all my tests but so far it's looking good.

Here is my function for getting the number of seconds of daylight 
savings time. Since this only seems to be an OS X problem, it doesn't 
matter that it relies on AppleScript.

function DSTseconds
   -- get current time zone & convert to decimal hours
   -- e.g. +0930 becomes 9.5
   put the internet date into tNow
   put last word of tNow into tZone
   replace "+" with empty in tZone
   put char -2 to -1 of tZone into tMins
   delete char -2 to -1 of tZone
   add tMins / 60 to tZone
   -- use AppleScript to get the current number of seconds between
   -- this computer's time & GMT, and convert to hours
   put "tell application " & quote & "Finder" & quote & "" & cr \
       & "return time to GMT" & cr & "end tell" into tScript
   do tScript as AppleScript
   put the result / 3600 into tDiff
   put (tDiff - tZone) * 3600 into tDST
   return tDST
end DSTseconds


On 8 Nov 2004, at 2:07 pm, Sarah Reichelt wrote:

> Hi All,
> I'm back onto my pet bug to do with time zones & daylight saving. In 
> Rev 2.5 the original bug is fixed so that convert does not add an hour 
> with each conversion if you are in a positive time zone with daylight 
> saving using Mac OS X.
> However, I am just deploying a major app in daylight savings affected 
> areas and having some problems because "the seconds" are not behaving 
> the way I expected.
> For example:
> 	set time zone to Brisbane (+1000), no daylight saving, get the seconds
> 	switch to Melbourne (+1000), with daylight saving, get the seconds
> allowing for the time needed to switch time zones, these both give the 
> same answer!
> If I use convert to change them to a readable date & time they give 
> times differing by 1 hour, which is correct.
> At this point I get so confused that I can't work out what is right & 
> what is wrong, but basically, seconds is not allowing for daylight 
> savings but is the same value at the same actual moment, regardless of 
> the daylight savings settings. Internally Rev handles this so that 
> converting the seconds accommodates to daylight saving times.
> As far as I am concerned, the major impact is that events occur in 
> remote machines (both with & without daylight saving) which get logged 
> with a time stamp in seconds format. These reports get emailed back to 
> base where there is no daylight saving and the times from machines 
> with daylight saving are then translated incorrectly so their reports 
> are an hour out.
> I am at a loss as to what to do. I guess if I can detect daylight 
> savings, I could add 3600 to the time stamps of any reports. But how 
> can I detect daylight savings? Rev must be able to do this, but I 
> can't find a way. Is there maybe an AppleScript way?
> Any words of encouragement, advice or help would be greatly 
> appreciated.
> Sarah
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution

More information about the use-livecode mailing list