atoomic / perl-TimeDate

time & date parsing and formatting perl library
http://search.cpan.org/dist/TimeDate/
1 stars 4 forks source link

TimeDate 1.20 tz2zone("America/Chicago") doesn't work [rt.cpan.org #76968] #29

Open atoomic opened 4 years ago

atoomic commented 4 years ago

Migrated from rt.cpan.org#76968 (status was 'open')

Requestors:

From cary.millsap@method-r.com on 2012-05-03 17:31:02 :

Graham,

Using Time::Zone in TimeDate v1.20, I've found that tz2zone() doesn't
convert time zones of the form "America/Chicago" to a value usable by
tz_offset. My OS (Mac OS X, Linux, Solaris) does consider TZ values of the
form "America/Chicago" to be valid:

$ zdump "America/Chicago"
America/Chicago  Thu May  3 12:23:16 2012 CDT

Here is a test in Perl that illustrates the problem:

$ more t.pl
use strict;
use warnings;
use Time::Zone;

$ENV{TZ} = "-0500";
printf "%20s %20s %20s\n", qw(input tz2zone tzoffset(tz2zone));
printf "%20s %20s %20s\n", '-'x20, '-'x20, '-'x20;
for (qw(-0500 CST6CDT America/Chicago)) {
        printf "%20s %20s %20s\n", $_, tz2zone($_),
tz_offset(tz2zone($_))//"undef";
}

$ perl t.pl
               input              tz2zone    tzoffset(tz2zone)
-------------------- -------------------- --------------------
               -0500                -0500               -18000
             CST6CDT                  CST               -21600
     America/Chicago      America/Chicago                undef

Thank you for looking into it.

Cary Millsap

From gbarr@pobox.com on 2012-05-03 17:38:42 :

On May 3, 2012, at 12:31 , Cary Millsap via RT wrote:
> Using Time::Zone in TimeDate v1.20, I've found that tz2zone() doesn't
> convert time zones of the form "America/Chicago" to a value usable by
> tz_offset. My OS (Mac OS X, Linux, Solaris) does consider TZ values of the
> form "America/Chicago" to be valid:

tz2zone was never intended to support named zones, it was intended to
convert the likes of -0800 etc.

I would suggest using DateTime::TimeZone to convert named timezones.

Graham.

From cary.millsap@method-r.com on 2012-05-03 17:52:04 :

Thank you, Graham. I'll look there.

Cary

On Thu, May 3, 2012 at 12:38 PM, Graham Barr via RT <
bug-TimeDate@rt.cpan.org> wrote:

> <URL: https://rt.cpan.org/Ticket/Display.html?id=76968 >
>
> On May 3, 2012, at 12:31 , Cary Millsap via RT wrote:
> > Using Time::Zone in TimeDate v1.20, I've found that tz2zone() doesn't
> > convert time zones of the form "America/Chicago" to a value usable by
> > tz_offset. My OS (Mac OS X, Linux, Solaris) does consider TZ values of
> the
> > form "America/Chicago" to be valid:
>
> tz2zone was never intended to support named zones, it was intended to
> convert the likes of -0800 etc.
>
> I would suggest using DateTime::TimeZone to convert named timezones.
>
> Graham.
>
>
>