Alaska Perl Mongers Site reworked. . .
Michael Fowler
wolfm at pobox.alaska.net
Wed Jul 28 14:55:35 CDT 1999
The strftime function has a (apparently undocumented) specifier, %z, on my
system. It returns an rfc822 numeric timezone, an offset from GMT.
I don't know how portable this is, considering it's undocumented. You may
want to use the Time::Timezone module, which provides the tz_local_offset and
tz_offset functions. Alternatively, you can use the Date::Format module's
strftime function, which documents the %z, and has quite a few other
specifiers besides. Both modules can be found on CPAN.
With any of the solutions you're going to get -0800, instead of just -8.
This is to allow for half-hour timezone offsets, as well as offsets above 9,
while still being easy to parse.
Michael
On Wed, Jul 28, 1999 at 11:15:54AM -0800, Leif Sawyer wrote:
> I've just stumbled across an interesting problem
> that I can't dredge up the answer to.
>
> I need a function to return the offset for the current timezone.
>
> I can do the following:
>
> perl -e 'use POSIX; print POSIX::strftime("%T %D (%Z)\n")'
>
> which outputs
>
> 11:10:00 07/28/99 (AKDT)
>
> What i need is to have:
>
> 11:10:00 07/28/99 -8 (AKDT)
>
> Any thoughts?
> =================================================
> Mailing list info: If at any time you wish to (un|re)subscribe to
> the list send the request to majordomo at hfb.pm.org. All requests
> should be in the body, and look like such
> subscribe anchorage-pm-list
> unsubscribe anchorage-pm-list
=================================================
Mailing list info: If at any time you wish to (un|re)subscribe to
the list send the request to majordomo at hfb.pm.org. All requests
should be in the body, and look like such
subscribe anchorage-pm-list
unsubscribe anchorage-pm-list
More information about the Anchorage-pm
mailing list