r34937 - in /branches/upstream/libdatetime-perl/current: Changes META.yml SIGNATURE lib/DateTime.pm lib/DateTime/Duration.pm t/03components.t t/04epoch.t t/38local-subtract.t t/41cldr_format.t
ryan52-guest at users.alioth.debian.org
ryan52-guest at users.alioth.debian.org
Fri May 8 06:25:22 UTC 2009
Author: ryan52-guest
Date: Fri May 8 06:25:17 2009
New Revision: 34937
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=34937
Log:
[svn-upgrade] Integrating new upstream version, libdatetime-perl (0.4900)
Modified:
branches/upstream/libdatetime-perl/current/Changes
branches/upstream/libdatetime-perl/current/META.yml
branches/upstream/libdatetime-perl/current/SIGNATURE
branches/upstream/libdatetime-perl/current/lib/DateTime.pm
branches/upstream/libdatetime-perl/current/lib/DateTime/Duration.pm
branches/upstream/libdatetime-perl/current/t/03components.t
branches/upstream/libdatetime-perl/current/t/04epoch.t
branches/upstream/libdatetime-perl/current/t/38local-subtract.t
branches/upstream/libdatetime-perl/current/t/41cldr_format.t
Modified: branches/upstream/libdatetime-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/Changes?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/Changes (original)
+++ branches/upstream/libdatetime-perl/current/Changes Fri May 8 06:25:17 2009
@@ -1,3 +1,34 @@
+0.49 2009-05-04
+
+- A bug in the test code for handling overloaded objects in from_epoch
+ resulted in a test failure on Perl 5.8.x. This release contains no
+ changes besides a test code fix.
+
+
+0.48 2009-05-04
+
+- Some of the accessors (the "main" ones like year(), month(), day(),
+ etc) now warn if they are passed a value. Patch from Shawn
+ Moore. Fixes RT #6979.
+
+- DateTime::Duration expected DateTime to be loaded and used some
+ constants from it, but did not explicitly "use DateTime". Reported
+ by Jeff Kubina. RT #44740.
+
+- The CLDR formatting for "c" and "cc" was incorrectly using the local
+ day of the week. This meant that it gave the wrong result for
+ locales where Monday is not considered the first day of the
+ week. Reported by Maros Kollar. RT #45007.
+
+- DateTime->from_epoch did not allow an object which overloaded
+ numification as the epoch value. Patch by Michael Schwern. RT
+ #45653.
+
+- Fixed how datetime subtraction is handled for some cases around DST
+ changes. This had been improved back in 0.30, but there were still
+ bugs. RT #45235.
+
+
0.47 2009-03-01
- The handling of CLDR format 'j' and 'jj' was backwards, using 24
Modified: branches/upstream/libdatetime-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/META.yml?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/META.yml (original)
+++ branches/upstream/libdatetime-perl/current/META.yml Fri May 8 06:25:17 2009
@@ -1,12 +1,14 @@
--- #YAML:1.0
name: DateTime
-version: 0.47
+version: 0.49
abstract: DateTime base objects
author:
- Dave Rolsky <autarch at urth.org>
license: perl
distribution_type: module
configure_requires:
+ ExtUtils::MakeMaker: 0
+build_requires:
ExtUtils::MakeMaker: 0
requires:
DateTime::Locale: 0.41
@@ -20,7 +22,7 @@
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.48
+generated_by: ExtUtils::MakeMaker version 6.50
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: branches/upstream/libdatetime-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/SIGNATURE?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/SIGNATURE (original)
+++ branches/upstream/libdatetime-perl/current/SIGNATURE Fri May 8 06:25:17 2009
@@ -15,19 +15,19 @@
Hash: SHA1
SHA1 c951898b770a16da2897d908ab6f9f72057bd570 CREDITS
-SHA1 88d8496a110f46fd04d3f14244a33b893a4635d0 Changes
+SHA1 69babd5cca5f20ce810101a43506733d3150c5c6 Changes
SHA1 584d54b142ddaf04e432663d0028561cbe44d5a0 DateTime.xs
SHA1 f235ba4160673bcb7c9d58c2f09dbc7fc0efadea LICENSE
SHA1 8ecb0421940e2c011413cc577e3ffeafd070248b MANIFEST
SHA1 4e2c3ce93609615474a50e56299fb1cadcd2c6fa MANIFEST.SKIP
-SHA1 5d21d1d784665b0eddc6b0e1a9ba4ae5c46f08af META.yml
+SHA1 45896940004fb7bbc38390a23ff246f16a5a6981 META.yml
SHA1 2e1f92628b4ac103434685b59a8f2507c08ee2fa Makefile.PL
SHA1 c9301a379ff7bb5bca2878ac0a2fe9fb1e74ae45 README
SHA1 bfc70fbe8fa29484452bea8c2ed4afd55218f2c2 TODO
SHA1 b67b906c9fbaab9ccac635d623cb4e6064feb8f0 leap_seconds.h
SHA1 ad083d04f765963b707dab9d566bf17e92fa51e9 leaptab.txt
-SHA1 a756363da9a4dca898b0c409a7c408b9a3381877 lib/DateTime.pm
-SHA1 e17e7dc0ab84f1ac9a97854894757975c5f4de0f lib/DateTime/Duration.pm
+SHA1 b80d5a6e93796d7847a5ad61524b9efb3250d012 lib/DateTime.pm
+SHA1 f9daeaca0e40389ee88e2834e2fac9457d2e92db lib/DateTime/Duration.pm
SHA1 3166fafcd4b8121470e5395ef8e00564edd33af1 lib/DateTime/Helpers.pm
SHA1 6bfc8fc10b9ae01458ab00f23eb967b734f073f5 lib/DateTime/Infinite.pm
SHA1 b0e9db0e850952e46814eb5e8af708b4dd9a44d2 lib/DateTime/LeapSecond.pm
@@ -37,8 +37,8 @@
SHA1 122a4ebd803e128a85cb4ea6f92f38de321108ea t/00load.t
SHA1 8b648ccc4b980620daa290b5e8c416102e0b947e t/01sanity.t
SHA1 cf0d0f3c76243ecf6c53b6101edd0531f1288144 t/02last_day.t
-SHA1 bd093f5d39400a0d234e8cae4ddec6f265e5b0bc t/03components.t
-SHA1 f78c850d1c16d7a78b8a6f6fab5fc389e42dbea8 t/04epoch.t
+SHA1 03a46626bf2b0dce51b88060c3f9fd85b7e7b1da t/03components.t
+SHA1 5474317ba0c6993fb7fb32791f88548176bacdf0 t/04epoch.t
SHA1 7723464e93d62748c480e77e06d7778b71f40aa3 t/05set.t
SHA1 b997ce5cc82d209e091ab10fc3c10e6826c6f878 t/06add.t
SHA1 9a83118f48281f7692454a4c3387105df9352f18 t/07compare.t
@@ -71,10 +71,10 @@
SHA1 33c93ecf4c9fa84c2452be2331688f10e2f6a66b t/35rd_values.t
SHA1 50cc2dac64a71d6a978ca331e715a8cabe0664ac t/36invalid_local.t
SHA1 ae0781e588abeaa190126689cad93b558e815ef7 t/37local-add.t
-SHA1 69ad635c579d55e725ead71026f8367ab4dde37b t/38local-subtract.t
+SHA1 7ddcd4a4ea0dc4364d82e3c8485c724e7be13c34 t/38local-subtract.t
SHA1 5463926117414ec4f0f1d600aec03d24d2eb0e24 t/39no-so.t
SHA1 38c1cc264996e606146bead0c3c0520c74efa1b4 t/40leap-years.t
-SHA1 0ec6551d372d0965b6e9a6dae1a51c9483645378 t/41cldr_format.t
+SHA1 0aed382d79a44eaa1b55b465eeeb003c2821559d t/41cldr_format.t
SHA1 e33a4df832d0b1acaee919cfda640ca094a81520 t/42duration_class.t
SHA1 25f497cf107c4135a293e54320c71c8da95ca64a t/pod-coverage.t
SHA1 37307177c8305132ecc2c9b0778f53fa48f1691e t/pod.t
@@ -82,7 +82,7 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
-iEYEARECAAYFAkmquB8ACgkQ3Or3ZzQuifNf5QCeJVImRJYsEJwaIInAdeGfa3a2
-IBgAoOGADSNUAWzSHOPDQluOB2HteU70
-=5oJB
+iEYEARECAAYFAkn/d5gACgkQ3Or3ZzQuifPbZgCfc2LMT6fFXsxJSS+V0zRTlwyo
+9wIAoJRyebqLO6bTLq+fkrWl7Rn2WVtQ
+=Dpqx
-----END PGP SIGNATURE-----
Modified: branches/upstream/libdatetime-perl/current/lib/DateTime.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/lib/DateTime.pm?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/lib/DateTime.pm (original)
+++ branches/upstream/libdatetime-perl/current/lib/DateTime.pm Fri May 8 06:25:17 2009
@@ -12,7 +12,7 @@
BEGIN
{
- $VERSION = '0.47';
+ $VERSION = '0.49';
my $loaded = 0;
unless ( $ENV{PERL_DATETIME_PP} )
@@ -438,7 +438,7 @@
}
{
- my $spec = { epoch => { type => SCALAR },
+ my $spec = { epoch => { regex => qr/^-?(?:\d+(?:\.\d*)?|\.\d+)$/ },
locale => { type => SCALAR | OBJECT, optional => 1 },
language => { type => SCALAR | OBJECT, optional => 1 },
time_zone => { type => SCALAR | OBJECT, optional => 1 },
@@ -612,7 +612,10 @@
sub clone { bless { %{ $_[0] } }, ref $_[0] }
-sub year { $_[0]->{local_c}{year} }
+sub year {
+ Carp::carp('year() is a read-only accessor') if @_ > 1;
+ return $_[0]->{local_c}{year};
+}
sub ce_year { $_[0]->{local_c}{year} <= 0 ?
$_[0]->{local_c}{year} - 1 :
@@ -633,7 +636,10 @@
sub year_with_christian_era { (abs $_[0]->ce_year) . $_[0]->christian_era }
sub year_with_secular_era { (abs $_[0]->ce_year) . $_[0]->secular_era }
-sub month { $_[0]->{local_c}{month} }
+sub month {
+ Carp::carp('month() is a read-only accessor') if @_ > 1;
+ return $_[0]->{local_c}{month};
+}
*mon = \&month;
sub month_0 { $_[0]->{local_c}{month} - 1 }
@@ -643,7 +649,10 @@
sub month_abbr { $_[0]->{locale}->month_format_abbreviated->[ $_[0]->month_0() ] }
-sub day_of_month { $_[0]->{local_c}{day} }
+sub day_of_month {
+ Carp::carp('day_of_month() is a read-only accessor') if @_ > 1;
+ $_[0]->{local_c}{day};
+}
*day = \&day_of_month;
*mday = \&day_of_month;
@@ -733,21 +742,33 @@
$self->year );
}
-sub hour { $_[0]->{local_c}{hour} }
+sub hour {
+ Carp::carp('hour() is a read-only accessor') if @_ > 1;
+ return $_[0]->{local_c}{hour};
+}
sub hour_1 { $_[0]->{local_c}{hour} == 0 ? 24 : $_[0]->{local_c}{hour} }
sub hour_12 { my $h = $_[0]->hour % 12; return $h ? $h : 12 }
sub hour_12_0 { $_[0]->hour % 12 }
-sub minute { $_[0]->{local_c}{minute} }
+sub minute {
+ Carp::carp('minute() is a read-only accessor') if @_ > 1;
+ return $_[0]->{local_c}{minute};
+}
*min = \&minute;
-sub second { $_[0]->{local_c}{second} }
+sub second {
+ Carp::carp('second() is a read-only accessor') if @_ > 1;
+ return $_[0]->{local_c}{second};
+}
*sec = \&second;
sub fractional_second { $_[0]->second + $_[0]->nanosecond / MAX_NANOSECONDS }
-sub nanosecond { $_[0]->{rd_nanosecs} }
+sub nanosecond {
+ Carp::carp('nanosecond() is a read-only accessor') if @_ > 1;
+ return $_[0]->{rd_nanosecs};
+}
sub millisecond { _round( $_[0]->{rd_nanosecs} / 1000000 ) }
@@ -866,7 +887,10 @@
return ( $first_wday_of_month <= 4 ) ? $wom + 1 : $wom;
}
-sub time_zone { $_[0]->{tz} }
+sub time_zone {
+ Carp::carp('time_zone() is a read-only accessor') if @_ > 1;
+ return $_[0]->{tz};
+}
sub offset { $_[0]->{tz}->offset_for_datetime( $_[0] ) }
sub _offset_for_local_datetime { $_[0]->{tz}->offset_for_local_datetime( $_[0] ) }
@@ -876,7 +900,10 @@
sub time_zone_long_name { $_[0]->{tz}->name }
sub time_zone_short_name { $_[0]->{tz}->short_name_for_datetime( $_[0] ) }
-sub locale { $_[0]->{locale} }
+sub locale {
+ Carp::carp('locale() is a read-only accessor') if @_ > 1;
+ return $_[0]->{locale};
+}
*language = \&locale;
sub utc_rd_values { @{ $_[0] }{ 'utc_rd_days', 'utc_rd_secs', 'rd_nanosecs' } }
@@ -1057,7 +1084,7 @@
qr/ccccc/ => sub { $_[0]->{locale}->day_stand_alone_narrow->[ $_[0]->day_of_week_0() ] },
qr/cccc/ => sub { $_[0]->{locale}->day_stand_alone_wide->[ $_[0]->day_of_week_0() ] },
qr/ccc/ => sub { $_[0]->{locale}->day_stand_alone_abbreviated->[ $_[0]->day_of_week_0() ] },
- qr/(cc?)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->local_day_of_week() ) },
+ qr/(cc?)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->day_of_week() ) },
qr/a/ => 'am_or_pm',
@@ -1229,7 +1256,7 @@
my $dt2 = shift;
$dt2 = $dt2->clone->set_time_zone( $dt1->time_zone )
- unless $dt1->time_zone->name eq $dt2->time_zone->name;
+ unless $dt1->time_zone eq $dt2->time_zone;
# We only want a negative duration if $dt2 > $dt1 ($self)
my ( $bigger, $smaller, $negative ) =
@@ -1275,8 +1302,7 @@
# - see 38local-subtract.t
my $bigger_min = $bigger->hour * 60 + $bigger->minute;
if ( $bigger->time_zone->has_dst_changes
- && ( $bigger->ymd ne $smaller->ymd
- || $bigger->is_dst != $smaller->is_dst )
+ && $bigger->is_dst != $smaller->is_dst
)
{
@@ -3332,8 +3358,8 @@
=head2 Formatters And Stringification
You can optionally specify a "formatter", which is usually a
-DateTime::Format::* object/class, to control how the stringification
-of the DateTime object.
+DateTime::Format::* object/class, to control the stringification of
+the DateTime object.
Any of the constructor methods can accept a formatter argument:
@@ -3351,6 +3377,10 @@
A formatter can be handy when you know that in your application you
want to stringify your DateTime objects into a special format all the
time, for example to a different language.
+
+If you provide a formatter class name or object, it must implement a
+C<format_datetime> method. This method will be called with just the
+DateTime object as its argument.
=head2 strftime Patterns
@@ -3728,8 +3758,8 @@
=item * e{1,2}
-The I<local> day of the week, from 1 to 7. This number depends on what
-day is considered the first day of the week, which varies by
+The I<local> numeric day of the week, from 1 to 7. This number depends
+on what day is considered the first day of the week, which varies by
locale. For example, in the US, Sunday is the first day of the week,
so this returns 2 for Monday.
@@ -3747,7 +3777,8 @@
=item * c
-The numeric day of the week (not localized).
+The numeric day of the week from 1 to 7, treating Monday as the first
+of the week, regardless of locale.
=item * ccc
Modified: branches/upstream/libdatetime-perl/current/lib/DateTime/Duration.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/lib/DateTime/Duration.pm?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/lib/DateTime/Duration.pm (original)
+++ branches/upstream/libdatetime-perl/current/lib/DateTime/Duration.pm Fri May 8 06:25:17 2009
@@ -3,6 +3,7 @@
use strict;
use Carp ();
+use DateTime;
use DateTime::Helpers;
use Params::Validate qw( validate SCALAR );
Modified: branches/upstream/libdatetime-perl/current/t/03components.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/t/03components.t?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/t/03components.t (original)
+++ branches/upstream/libdatetime-perl/current/t/03components.t Fri May 8 06:25:17 2009
@@ -2,7 +2,7 @@
use strict;
-use Test::More tests => 135;
+use Test::More tests => 144;
use DateTime;
@@ -295,3 +295,29 @@
is( $dt->hour_12, 12, '->hour_12' );
is( $dt->hour_12_0, 0, '->hour_12_0' );
}
+
+SKIP:
+{
+ skip 'These tests require Test::Exception', 9
+ unless eval "use Test::Warn; 1";
+
+ my $dt = DateTime->new( year => 2000 );
+ warnings_like( sub { $dt->year(2001) }, qr/is a read-only/,
+ 'year() is read-only' );
+ warnings_like( sub { $dt->month(5) }, qr/is a read-only/,
+ 'month() is read-only' );
+ warnings_like( sub { $dt->day(5) }, qr/is a read-only/,
+ 'day() is read-only' );
+ warnings_like( sub { $dt->hour(5) }, qr/is a read-only/,
+ 'hour() is read-only' );
+ warnings_like( sub { $dt->minute(5) }, qr/is a read-only/,
+ 'minute() is read-only' );
+ warnings_like( sub { $dt->second(5) }, qr/is a read-only/,
+ 'second() is read-only' );
+ warnings_like( sub { $dt->nanosecond(5) }, qr/is a read-only/,
+ 'nanosecond() is read-only' );
+ warnings_like( sub { $dt->time_zone('America/Chicago') }, qr/is a read-only/,
+ 'time_zone() is read-only' );
+ warnings_like( sub { $dt->locale('en_US') }, qr/is a read-only/,
+ 'locale() is read-only' );
+}
Modified: branches/upstream/libdatetime-perl/current/t/04epoch.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/t/04epoch.t?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/t/04epoch.t (original)
+++ branches/upstream/libdatetime-perl/current/t/04epoch.t Fri May 8 06:25:17 2009
@@ -2,7 +2,7 @@
use strict;
-use Test::More tests => 32;
+use Test::More tests => 38;
use DateTime;
@@ -121,3 +121,45 @@
is( $dt->day, 1, 'day should be 1904' );
}
+{
+ package Number::Overloaded;
+ use overload
+ "0+" => sub { $_[0]->{num} },
+ fallback => 1;
+
+ sub new { bless { num => $_[1] }, $_[0] }
+}
+
+{
+ my $time = Number::Overloaded->new(12345);
+
+ my $dt = DateTime->from_epoch( epoch => $time );
+ is( $dt->epoch, 12345, 'can pass overloaded object to from_epoch' );
+
+ $time = Number::Overloaded->new(-12345);
+ $dt = DateTime->from_epoch( epoch => $time );
+
+ is( $dt->epoch, -12345, 'negative epoch in overloaded object' );
+
+ $time = Number::Overloaded->new(12345.1234);
+ $dt = DateTime->from_epoch( epoch => $time );
+ is( $dt->epoch, 12345, 'decimal epoch in overloaded object' );
+}
+
+{
+ my @tests = ( 'asldkjlkjd',
+ '1234 foo',
+ 'adlkj 1234',
+ );
+
+ for my $test (@tests)
+ {
+ eval
+ {
+ DateTime->from_epoch( epoch => $test );
+ };
+
+ like( $@, qr/did not pass regex check/,
+ qq{'$test' is not a valid epoch value} );
+ }
+}
Modified: branches/upstream/libdatetime-perl/current/t/38local-subtract.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/t/38local-subtract.t?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/t/38local-subtract.t (original)
+++ branches/upstream/libdatetime-perl/current/t/38local-subtract.t Fri May 8 06:25:17 2009
@@ -2,7 +2,7 @@
use strict;
-use Test::More tests => 124;
+use Test::More tests => 127;
use DateTime;
@@ -181,12 +181,12 @@
{
my $dt1 = DateTime->new( year => 2003, month => 4, day => 6,
hour => 1, minute => 58,
- time_zone => "America/Chicago",
+ time_zone => 'America/Chicago',
);
my $dt2 = DateTime->new( year => 2003, month => 4, day => 6,
hour => 3, minute => 1,
- time_zone => "America/Chicago",
+ time_zone => 'America/Chicago',
);
my $dur = $dt2->subtract_datetime($dt1);
@@ -207,12 +207,12 @@
{
my $dt1 = DateTime->new( year => 2003, month => 4, day => 5,
hour => 1, minute => 58,
- time_zone => "America/Chicago",
+ time_zone => 'America/Chicago',
);
my $dt2 = DateTime->new( year => 2003, month => 4, day => 6,
hour => 3, minute => 1,
- time_zone => "America/Chicago",
+ time_zone => 'America/Chicago',
);
my $dur = $dt2->subtract_datetime($dt1);
@@ -260,12 +260,12 @@
{
my $dt1 = DateTime->new( year => 2003, month => 4, day => 6,
hour => 3, minute => 1,
- time_zone => "America/Chicago",
+ time_zone => 'America/Chicago',
);
my $dt2 = DateTime->new( year => 2003, month => 4, day => 7,
hour => 3, minute => 2,
- time_zone => "America/Chicago",
+ time_zone => 'America/Chicago',
);
my $dur = $dt2->subtract_datetime($dt1);
@@ -291,12 +291,12 @@
{
my $dt1 = DateTime->new( year => 2003, month => 4, day => 5,
hour => 1, minute => 58,
- time_zone => "America/Chicago",
+ time_zone => 'America/Chicago',
);
my $dt2 = DateTime->new( year => 2003, month => 4, day => 7,
hour => 2, minute => 1,
- time_zone => "America/Chicago",
+ time_zone => 'America/Chicago',
);
my $dur = $dt2->subtract_datetime($dt1);
@@ -423,11 +423,11 @@
{
my $dt1 = DateTime->new( year => 2005, month => 4, day => 3,
hour => 7, minute => 0,
- time_zone => "America/New_York" );
+ time_zone => 'America/New_York' );
my $dt2 = DateTime->new( year => 2005, month => 4, day => 3,
hour => 8, minute => 0,
- time_zone => "America/New_York" );
+ time_zone => 'America/New_York' );
my $dur = $dt2->subtract_datetime($dt1);
my ( $minutes, $seconds ) = $dur->in_units( 'minutes','seconds' );
@@ -442,8 +442,61 @@
{
my $dt1 = DateTime->new( year => 2005, month => 4, day => 3,
hour => 1, minute => 0,
- time_zone => "America/New_York" );
+ time_zone => 'America/New_York' );
my $dur = $dt1->subtract_datetime($dt1);
ok( $dur->is_zero, 'dst change date (with dst) - itself, duration is zero' );
}
+
+# This tests a bug where one of the datetimes is changing DST, and the
+# other is not. In this case, no "adjustments" (aka hacks) are made in
+# subtract_datetime, and it just gives the "UTC difference".
+{
+ # This is UTC-4
+ my $dt1 = DateTime->new( year => 2009, month => 3, day => 9,
+ time_zone => 'America/New_York' );
+ # This is UTC+8
+ my $dt2 = DateTime->new( year => 2009, month => 3, day => 9,
+ time_zone => 'Asia/Hong_Kong' );
+
+ my $dur = $dt1->subtract_datetime($dt2);
+
+ is( $dur->delta_minutes, 720,
+ 'subtraction the day after a DST change in one zone, where the other datetime is in a different zone' );
+}
+
+{
+ # This is UTC-5
+ my $dt1 = DateTime->new( year => 2009, month => 3, day => 8,
+ hour => 1,
+ time_zone => 'America/New_York' );
+ # This is UTC+8
+ my $dt2 = DateTime->new( year => 2009, month => 3, day => 8,
+ hour => 1,
+ time_zone => 'Asia/Hong_Kong' );
+
+ my $dur = $dt1->subtract_datetime($dt2);
+
+ is( $dur->delta_minutes, 780,
+ 'subtraction the day of a DST change in one zone (before the change),'
+ . ' where the other datetime is in a different zone' );
+}
+
+
+{
+ # This is UTC-4
+ my $dt1 = DateTime->new( year => 2009, month => 3, day => 8,
+ hour => 4,
+ time_zone => 'America/New_York' );
+ # This is UTC+8
+ my $dt2 = DateTime->new( year => 2009, month => 3, day => 8,
+ hour => 4,
+ time_zone => 'Asia/Hong_Kong' );
+
+ my $dur = $dt1->subtract_datetime($dt2);
+
+ is( $dur->delta_minutes, 720,
+ 'subtraction the day of a DST change in one zone (after the change),'
+ . ' where the other datetime is in a different zone' );
+}
+
Modified: branches/upstream/libdatetime-perl/current/t/41cldr_format.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libdatetime-perl/current/t/41cldr_format.t?rev=34937&op=diff
==============================================================================
--- branches/upstream/libdatetime-perl/current/t/41cldr_format.t (original)
+++ branches/upstream/libdatetime-perl/current/t/41cldr_format.t Fri May 8 06:25:17 2009
@@ -2,7 +2,7 @@
use warnings;
use utf8;
-use Test::More tests => 97;
+use Test::More tests => 101;
use DateTime;
@@ -204,3 +204,32 @@
is( $dt->format_cldr('j'), '18',
'format_cldr for j in fr should be 18 (at 18:34)' );
}
+
+{
+ my $dt = DateTime->new( year => 2009,
+ month => 4,
+ day => 13,
+ locale => 'en_US',
+ );
+
+ is( $dt->format_cldr('e'), '2',
+ 'format_cldr for e in en_US should be 2 (for Monday, 2009-04-13)' );
+
+ is( $dt->format_cldr('c'), '1',
+ 'format_cldr for c in en_US should be 1 (for Monday, 2009-04-13)' );
+}
+
+
+{
+ my $dt = DateTime->new( year => 2009,
+ month => 4,
+ day => 13,
+ locale => 'fr_FR',
+ );
+
+ is( $dt->format_cldr('e'), '1',
+ 'format_cldr for e in fr_FR should be 1 (for Monday, 2009-04-13)' );
+
+ is( $dt->format_cldr('c'), '1',
+ 'format_cldr for c in fr_FR should be 1 (for Monday, 2009-04-13)' );
+}
More information about the Pkg-perl-cvs-commits
mailing list