City daylight savings time

Hi,

If a city or country changes to daylight savings time, does Apple update your computer to reflect this change? For instance, Chili changed to DST of 1 hour. Do you have to modify your script or has Apple updated it?
http://www.timeanddate.com/worldclock/clockchange.html?n=232

Edited: that’s ok. I reread the “time to gmt” post and remembered that the user has to set DST on or off and is not in the TZ database (I think).

Thanks,
kel

If the System PreferencePane Date & Time is set to “set date time automatically” the daylight savings time is applied automatically.
I am living in France with daylight savings time and since 2004/01/01 I never applied change by hand.

Of course this apply for a machine which is connected, at least from time to time, to the net.

KOENIG Yvan (VALLAURIS, France) vendredi 13 septembre 2013 09:09:50

It should happen regardless.

Hi,

So I assume that Apple has updated the ‘Set date and time automatically:’ for Chili. I was planning to try and check this out somehow when I get back.

Thanks,
kel

Hello.

I haven’t figured out precisely how this works, but this is something I believe unix takes care, probably a kernel extenstion.

It does so at the right time, because in the date and time part of the locale info in /usr/share, there is zone info files, that are compiled, and contains exactly that information. This was a topic not a long time ago.

Basically, when you either change your localization in the time preferences, or when you boot, I guess that this information is read in, and after that, it is a timer like mechanism, that sees if it has to change the time settings within the next 24 hours or so.

As I said, there was a whole thread about this recently, the files and such: this thread contains applicable information follow the link in post #6. (Not the white rabbit. :slight_smile: )

Hi McUsr,

Yes, for America/Santiago, I just checked the time to gmt in the summer (-4 hours) and now it’s (-3 hours). Wonder where they keep that stuff also.

I have to add Nigel’s modificaitons (from the link) to the formatting in the following script I’ve used to test that:

on TZtoTZ(TZ1date, TZ1, TZ2)
	return (do shell script ("eraTime=$(TZ=" & TZ1 & " date -jf '%Y-%m-%dT%H:%M:%S' '" & (TZ1date as «class isot» as string) & "' '+%s') ; TZ=" & TZ2 & " date -r  \"$eraTime\" '+%Y-%m-%dT%H:%M:%S'") as «class isot») as date
end TZtoTZ

on timeToGMT on dt for TZ
	return dt - TZtoTZ(dt, TZ, "GMT")
end timeToGMT

set dt1 to date ("09/13/2013 12:00")
set localTZ to "America/Santiago"
timeToGMT on dt1 for localTZ
set r to result
r / 3600

Thanks,
kel

Hello.

I executed apropos timezone in a terminal window, (man -k timezone would have returned the same) then I got as a result: timezone(3) - return the timezone abbreviation tzfile(5) - timezone information zdump(8) - timezone dumper zic(8) - timezone compiler
I think man -s8 zic will tell you what you are curious about. :slight_smile: b[/b]

Hi McUsr,

Yeah, at a quick glance, that looks like it. It seems to give the start and end times also for DST.

I never realized that in the southern hemisphere, daylight savings time would work opposite from that in the northern hemisphere.

Thanks a lot and have a good day,
kel

Hello

There is a lot of stuff in this street, that aren’t exactly as you’d think they are, -so it is good to brush up some, or brush away old assumptions. Its refreshing!

For instance, you can only use AppleScript time to gmt handler when you use it for the current date, otherwise, you’ll have to figure out the gmt for that day.
And the gmt for a day on a given date, is good for almost anything concerning solar days, as long as you aren’t going to do anything astronmical, if, then you will have to resort to physical time to gmt, and eventually adjust with your your offset from Greenwich with your longitude converted to hours, minutes and seconds.

Hi,

I was looking at the unix zdump and think that that might give the DST info. From man dump for -v:

For me, zic was a little too hard to use at the time. So this seems to work for now and I just need to parse the text probably with Sed.

set cmd to "zdump -v America/Santiago | sed -n '/2013/p'"
do shell script cmd

I couldn’t find ‘zic’ examples for getting DST start and end times.

I’ve really thought about this and my conclusion is that they should call it daylight losing time in the southern hemisphere.

I suggest you think again – it’s all a question of timing. Hint: it begins here at the end of next month.

Hi Shane,

Interesting puzzle. What happens at the end of next month? The opposite of saving is losing? I don’t know.

Darn chickens making all their noise. Can’t sleep.

Are you sure it’s not at the end of this month?

You’re missing the fact that we’re now moving towards summer, not away from it.

It depends where you are, but yes, it’s not the end of the month.

set myZone to current application's NSTimeZone's systemTimeZone()
--> Australia/Melbourne (AEST) offset 36000
myZone's isDaylightSavingTime()
--> 0
set theDate to myZone's nextDaylightSavingTimeTransition()
--> 2013-10-05 16:00:00 +0000
myZone's isDaylightSavingTimeForDate_(theDate)
--> 1
myZone's nextDaylightSavingTimeTransitionAfterDate_(theDate)
--> 2014-04-05 16:00:00 +0000


I’m a bit surprised by the hour figures provided there, given our GMT offset is +10/11 hours.

Edited to change the variable name to something less confusing.

Saturday at 16:00:00 (GMT) equates to Sunday at 02:00:00 (+10 hours) or Sunday at 03:00:00 (+11 hours). Are those not the times your clocks go forward and back?

Yes, they’re right – for some reason I was subtracting 10/11 instead of adding.

Hi Shane,

Thanks for the Cocoa-Applescript example. NSTimeZone seems to have everything.

Thanks a lot,
kel

Hi Shane,

NSTimeZone is great. I can use this if I switch the script over to Xcode.

This is the first time I’ve used your app “ASObjC Runner” to test the Cocoa-AppleScript and that’s working great also. You can see the results!

Thanks a lot,
kel