• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Is this legit? [POSIX]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is this legit? [POSIX]


  • Subject: Is this legit? [POSIX]
  • From: "Nigel Garvey" <email@hidden>
  • Date: Wed, 23 Jul 2008 16:14:55 +0100

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?

NG

 _______________________________________________
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

  • Follow-Ups:
    • Re: Is this legit? [POSIX]
      • From: "Nigel Garvey" <email@hidden>
    • Re: Is this legit? [POSIX]
      • From: Axel Luttgens <email@hidden>
    • Re: Is this legit? [POSIX]
      • From: Philip Aker <email@hidden>
    • Re: Is this legit? [POSIX]
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: collect set of responses messages
  • Next by Date: Re: Is this legit? [POSIX]
  • Previous by thread: Re: collect set of responses messages
  • Next by thread: Re: Is this legit? [POSIX]
  • Index(es):
    • Date
    • Thread