FAQ
Hi, with these patches, DateTime::TimeZone->new('local')
will work properly under the cirtcumstances with TZ=JST-9
(common setting in Japan, means TZ=+0900).

Regards,
Kenichi Ishigaki

==========
diff -ru DateTime-TimeZone-0.46/lib/DateTime/TimeZone/Local.pm
DateTime-TimeZone-0.46-patched/lib/DateTime/TimeZone/Local.pm
--- DateTime-TimeZone-0.46/lib/DateTime/TimeZone/Local.pm 2006-05-09
06:42:05.000000000 +0900
+++ DateTime-TimeZone-0.46-patched/lib/DateTime/TimeZone/Local.pm 2006-07-30
03:12:25.186375000 +0900
@@ -228,7 +228,10 @@
return 0 unless defined $_[0];
return 0 if $_[0] eq 'local';

- return $_[0] =~ m,^[\w/]+$, ? 1 : 0;
+ return 1 if $_[0] =~ m,^[\w/]+$,;
+ return 1 if $_[0] =~ m,^\w+\s*[\+\-]\s*\d+$,;
+
+ return 0;
}


diff -ru DateTime-TimeZone-0.46/lib/DateTime/TimeZone.pm
DateTime-TimeZone-0.46-patched/lib/DateTime/TimeZone.pm
--- DateTime-TimeZone-0.46/lib/DateTime/TimeZone.pm 2006-05-09
06:42:05.000000000 +0900
+++ DateTime-TimeZone-0.46-patched/lib/DateTime/TimeZone.pm 2006-07-30
03:41:15.264500000 +0900
@@ -448,6 +448,13 @@
{
( $sign, $hours, $minutes, $seconds ) = ( $1, $2, $3, $4 );
}
+ # allow "TZ = JST - 9" format; this is equivalent TZ = +0900
+ elsif ( $offset =~ /^(\w+)\s*([\+\-])\s*(\d{1,2})$/ )
+ {
+ my $zone;
+ ( $zone, $sign, $hours, $minutes, $seconds ) = ( $1, $2, $3, 0, 0 );
+ $sign =~ tr/\+\-/-+/ unless uc $zone eq 'UTC';
+ }
else
{
return undef;
diff -ru DateTime-TimeZone-0.46/t/04local.t
DateTime-TimeZone-0.46-patched/t/04local.t
--- DateTime-TimeZone-0.46/t/04local.t 2006-05-09 06:42:05.000000000 +0900
+++ DateTime-TimeZone-0.46-patched/t/04local.t 2006-07-30
03:19:35.561375000 +0900
@@ -10,7 +10,7 @@

BEGIN { require 'check_datetime_version.pl' }

-plan tests => 19;
+plan tests => 21;

use DateTime::TimeZone;

@@ -46,6 +46,22 @@
local *DateTime::TimeZone::Local::_local_from_etc_timezone = sub { undef };
$^W = 1;

+ local $ENV{TZ} = 'JST - 9';
+
+ my $tz;
+ eval { $tz = DateTime::TimeZone->new( name => 'local' ) };
+ is( $@, '', 'valid time zone name in $ENV{TZ} should not die' );
+ isa_ok( $tz, 'DateTime::TimeZone::OffsetOnly' );
+}
+
+{
+ $^W = 0;
+ local *DateTime::TimeZone::Local::_from_etc_localtime = sub { undef };
+ local *DateTime::TimeZone::Local::_read_etc_sysconfig_clock = sub
{ undef };
+ local *DateTime::TimeZone::Local::_read_etc_default_init = sub { undef };
+ local *DateTime::TimeZone::Local::_local_from_etc_timezone = sub { undef };
+ $^W = 1;
+
local $ENV{TZ} = 'Africa/Kinshasa';

my $tz;

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
groupdatetime @
categoriesperl
postedJul 29, '06 at 11:38p
activeNov 9, '06 at 8:20a
posts3
users3
websitemetacpan.org...

People

Translate

site design / logo © 2021 Grokbase