Re: Is this legit? [POSIX]
Re: Is this legit? [POSIX]
- Subject: Re: Is this legit? [POSIX]
- From: Philip Aker <email@hidden>
- Date: Wed, 23 Jul 2008 11:32:04 -0700
On 08-07-23, at 08:14, Nigel Garvey wrote: I've been looking for a way to get the name of the time zone in which a machine's currently operating (eg. "Europe/London"). While following clues in parts of the system where I don't normally venture, I've noticed that if I coerce "/etc/localtime" to POSIX file, the reference changes to the current time zone file:
file "PowerBook HD:usr:share:zoneinfo:Europe:London"
I can coerce this to Unicode text (to avoid some ambiguity with the POSIX file) and get the POSIX path of the result, which gives a text ending with the very information I want:
set tzPath to POSIX path of ("/etc/localtime" as POSIX file as Unicode text) set astid to AppleScript's text item delimiters set AppleScript's text item delimiters to "zoneinfo/" set tz to text item 2 of tzPath set AppleScript's text item delimiters to astid tz --> "Europe/London"
This works for other time zones too. But is the "/etc/localtime" coercion trick a legitimate usage, or is it just something that happens to work in Tiger and Jaguar?
I wonder about the relationship between the above and:
set city to (do shell script "defaults read /Library/Preferences/.GlobalPreferences com.apple.TimeZonePref.Last_Selected_City") words of paragraph 5 of city
Philip Aker
Democracy: Two wolves and a sheep voting on lunch.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden