develooper Front page | perl.macperl.toolbox | Postings from May 2003

Re: [MacPerl] Re: Timezone information

Thread Previous
From:
Detlef Lindenthal
Date:
May 6, 2003 14:59
Subject:
Re: [MacPerl] Re: Timezone information
Message ID:
3EB80D0C.25B9BADA@lindenthal.com
Rick Measham wrote:

> In article <pudge-F548E6.07445406052003@onion.valueclick.com>,
>  pudge@pobox.com (Chris Nandor) wrote:
>
> > In article <BADC383D.47B%rickm@iSite.net.au>,
> >  rickm@iSite.net.au (Rick Measham) wrote:
> >
> > > I figure that as I've set my timezone in the system, there must be some way
> > > to get it back using MacPerl.
> > >
> > > I figure there's either an OSA hook that will tell me what it is, or there's
> > > a toolbox call that I can (somehow) make.
> >
> >    #!perl
> >    use Time::Local;
> >    $diff = (timelocal(localtime) - timelocal(gmtime)) / 36;
> >    $diff = sprintf "%+0.4d", $diff;  # add sign, leading zero(es)
> >    print $diff;
> >
> > That will give you the standard TZ offset (e.g., "-0400").
>
> Sorry Chris, I didn't explain myself too well. I'm looking for the name
> of the zone. It seems to be stored in the resource fork of 'Date & Time
> Preferences' (possibly ID256 of the 'pref' resources), but it's not in
> plain text. Maybe its an offset. Any ideas? Is it anywhere useful, or do
> I have to work out how this preferences file is encoded?
>
> Cheers!
> Rick

Given the time zone offset, you can derive the time zone name from
      http://timeanddate.com/time/abbrevations.html ;
put those names into one perl list and call that list with the appropriate index.
If those names are not enough, look at
     http://worldtimezone.com/wtz-names/timezonenames.html.

Good luck!

Detlef



Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About