commit perl-DateTime for openSUSE:Factory
![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package perl-DateTime for openSUSE:Factory checked in at 2014-07-25 12:27:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-DateTime (Old) and /work/SRC/openSUSE:Factory/.perl-DateTime.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "perl-DateTime" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-DateTime/perl-DateTime.changes 2014-03-09 18:37:38.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-DateTime.new/perl-DateTime.changes 2014-07-25 12:27:55.000000000 +0200 @@ -1,0 +2,33 @@ +Fri Jul 25 09:32:09 UTC 2014 - coolo@suse.com + +- updated to 1.10 + + - Some tests added in 1.09 would fail on a Perl without a 64-bit + gmtime(). Reported by Jerome Eteve. RT #95345. + + + 1.09 2014-05-03 + + - A call to ->truncate( to => 'week' ) could fail but leave the object + changed. RT #93347. + + - The value of ->jd() is now calculated based on ->mjd() instead of the other + way around. This reduces floating point errors a bit when calculating MJD, + and should have a neglible impact on the accuracy of JD. Reported by Anye + Li. RT #92972. See the ticket for a more detailed description of what this + fixes. + + - Attempting to construct a DateTime object with a year >= 5000 and a time + zone other than floating or DST now issues a warning. This warning may go + away once DateTime::TimeZone is made much faster. Inspired by a bug report + from Lloyd Fournier. RT #92655. + + + 1.08 2014-03-11 + + - DateTime now calls DateTime->_core_time() instead of calling Perl's time() + built-in directly. This makes it much easier to override the value of time() + that DateTime sees. This may make it easier to write tests for code that + uses DateTime . + +------------------------------------------------------------------- Old: ---- DateTime-1.07.tar.gz New: ---- DateTime-1.10.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-DateTime.spec ++++++ --- /var/tmp/diff_new_pack.xFewnG/_old 2014-07-25 12:27:56.000000000 +0200 +++ /var/tmp/diff_new_pack.xFewnG/_new 2014-07-25 12:27:56.000000000 +0200 @@ -17,7 +17,7 @@ Name: perl-DateTime -Version: 1.07 +Version: 1.10 Release: 0 %define cpan_name DateTime Summary: A date and time object @@ -34,6 +34,7 @@ BuildRequires: perl(Params::Validate) >= 0.76 BuildRequires: perl(Test::Fatal) BuildRequires: perl(Test::More) >= 0.88 +BuildRequires: perl(Test::Warnings) >= 0.005 BuildRequires: perl(Try::Tiny) Requires: perl(DateTime::Locale) >= 0.41 Requires: perl(DateTime::TimeZone) >= 1.09 ++++++ DateTime-1.07.tar.gz -> DateTime-1.10.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/Build.PL new/DateTime-1.10/Build.PL --- old/DateTime-1.07/Build.PL 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/Build.PL 2014-05-05 03:26:50.000000000 +0200 @@ -19,7 +19,7 @@ "Dave Rolsky <autarch\@urth.org>" ], "dist_name" => "DateTime", - "dist_version" => "1.07", + "dist_version" => "1.10", "license" => "artistic_2", "module_name" => "DateTime", "recommends" => {}, @@ -40,13 +40,15 @@ "perl" => "5.008001", "strict" => 0, "vars" => 0, - "warnings" => 0 + "warnings" => 0, + "warnings::register" => 0 }, "script_files" => [], "test_requires" => { "Storable" => 0, "Test::Fatal" => 0, "Test::More" => "0.88", + "Test::Warnings" => "0.005", "utf8" => 0 } ); @@ -57,6 +59,7 @@ "Storable" => 0, "Test::Fatal" => 0, "Test::More" => "0.88", + "Test::Warnings" => "0.005", "utf8" => 0 ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/Changes new/DateTime-1.10/Changes --- old/DateTime-1.07/Changes 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/Changes 2014-05-05 03:26:50.000000000 +0200 @@ -1,3 +1,34 @@ +1.10 2014-05-05 + +- Some tests added in 1.09 would fail on a Perl without a 64-bit + gmtime(). Reported by Jerome Eteve. RT #95345. + + +1.09 2014-05-03 + +- A call to ->truncate( to => 'week' ) could fail but leave the object + changed. RT #93347. + +- The value of ->jd() is now calculated based on ->mjd() instead of the other + way around. This reduces floating point errors a bit when calculating MJD, + and should have a neglible impact on the accuracy of JD. Reported by Anye + Li. RT #92972. See the ticket for a more detailed description of what this + fixes. + +- Attempting to construct a DateTime object with a year >= 5000 and a time + zone other than floating or DST now issues a warning. This warning may go + away once DateTime::TimeZone is made much faster. Inspired by a bug report + from Lloyd Fournier. RT #92655. + + +1.08 2014-03-11 + +- DateTime now calls DateTime->_core_time() instead of calling Perl's time() + built-in directly. This makes it much easier to override the value of time() + that DateTime sees. This may make it easier to write tests for code that + uses DateTime . + + 1.07 2014-02-06 - Added a hack to get this module working on Android. RT #92671. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/MANIFEST new/DateTime-1.10/MANIFEST --- old/DateTime-1.07/MANIFEST 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/MANIFEST 2014-05-05 03:26:50.000000000 +0200 @@ -1,4 +1,4 @@ -# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.012. +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.015. Build.PL CREDITS Changes @@ -66,6 +66,8 @@ t/42duration-class.t t/43new-params.t t/44set-formatter.t +t/45core-time.t +t/46warnings.t t/author-test-all-my-deps.t t/release-cpan-changes.t t/release-eol.t @@ -117,4 +119,6 @@ t/release-pp-42duration-class.t t/release-pp-43new-params.t t/release-pp-44set-formatter.t +t/release-pp-45core-time.t +t/release-pp-46warnings.t tools/leap_seconds_header.pl diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/META.json new/DateTime-1.10/META.json --- old/DateTime-1.07/META.json 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/META.json 2014-05-05 03:26:50.000000000 +0200 @@ -4,7 +4,7 @@ "Dave Rolsky <autarch@urth.org>" ], "dynamic_config" : 0, - "generated_by" : "Dist::Zilla version 5.012, CPAN::Meta::Converter version 2.131560", + "generated_by" : "Dist::Zilla version 5.015, CPAN::Meta::Converter version 2.120921", "license" : [ "artistic_2" ], @@ -26,7 +26,6 @@ }, "develop" : { "requires" : { - "Test::CPAN::Changes" : "0.19", "Test::More" : "0", "Test::NoTabs" : "0", "Test::Pod" : "1.41" @@ -49,7 +48,8 @@ "perl" : "5.008001", "strict" : "0", "vars" : "0", - "warnings" : "0" + "warnings" : "0", + "warnings::register" : "0" } }, "test" : { @@ -57,6 +57,7 @@ "Storable" : "0", "Test::Fatal" : "0", "Test::More" : "0.88", + "Test::Warnings" : "0.005", "utf8" : "0" } } @@ -73,7 +74,7 @@ "web" : "http://git.urth.org/DateTime.pm.git" } }, - "version" : "1.07", + "version" : "1.10", "x_authority" : "cpan:DROLSKY" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/META.yml new/DateTime-1.10/META.yml --- old/DateTime-1.07/META.yml 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/META.yml 2014-05-05 03:26:50.000000000 +0200 @@ -7,11 +7,12 @@ Storable: 0 Test::Fatal: 0 Test::More: 0.88 + Test::Warnings: 0.005 utf8: 0 configure_requires: Module::Build: 0.3601 dynamic_config: 0 -generated_by: 'Dist::Zilla version 5.012, CPAN::Meta::Converter version 2.131560' +generated_by: 'Dist::Zilla version 5.015, CPAN::Meta::Converter version 2.120921' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -34,8 +35,9 @@ strict: 0 vars: 0 warnings: 0 + warnings::register: 0 resources: bugtracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime repository: git://git.urth.org/DateTime.pm.git -version: 1.07 +version: 1.10 x_authority: cpan:DROLSKY diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/README new/DateTime-1.10/README --- old/DateTime-1.07/README 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/README 2014-05-05 03:26:50.000000000 +0200 @@ -1,7 +1,7 @@ This archive contains the distribution DateTime, -version 1.07: +version 1.10: A date and time object @@ -12,5 +12,5 @@ The Artistic License 2.0 (GPL Compatible) -This README file was generated by Dist::Zilla::Plugin::Readme v5.012. +This README file was generated by Dist::Zilla::Plugin::Readme v5.015. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/dist.ini new/DateTime-1.10/dist.ini --- old/DateTime-1.07/dist.ini 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/dist.ini 2014-05-05 03:26:50.000000000 +0200 @@ -3,7 +3,7 @@ license = Artistic_2_0 copyright_holder = Dave Rolsky -version = 1.07 +version = 1.10 [NextRelease] format = %-6v %{yyyy-MM-dd}d @@ -39,9 +39,9 @@ do_munging = 0 [EOLTests] -[NoTabsTests] [PodSyntaxTests] [Test::CPAN::Changes] +[Test::NoTabs] [Test::Pod::LinkCheck] ;[Test::Pod::No404s] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/lib/DateTime/Duration.pm new/DateTime-1.10/lib/DateTime/Duration.pm --- old/DateTime-1.07/lib/DateTime/Duration.pm 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/lib/DateTime/Duration.pm 2014-05-05 03:26:50.000000000 +0200 @@ -1,5 +1,5 @@ package DateTime::Duration; -$DateTime::Duration::VERSION = '1.07'; +$DateTime::Duration::VERSION = '1.10'; use strict; use warnings; @@ -315,7 +315,7 @@ =head1 VERSION -version 1.07 +version 1.10 =head1 SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/lib/DateTime/Helpers.pm new/DateTime-1.10/lib/DateTime/Helpers.pm --- old/DateTime-1.07/lib/DateTime/Helpers.pm 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/lib/DateTime/Helpers.pm 2014-05-05 03:26:50.000000000 +0200 @@ -1,5 +1,5 @@ package DateTime::Helpers; -$DateTime::Helpers::VERSION = '1.07'; +$DateTime::Helpers::VERSION = '1.10'; use strict; use warnings; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/lib/DateTime/Infinite.pm new/DateTime-1.10/lib/DateTime/Infinite.pm --- old/DateTime-1.07/lib/DateTime/Infinite.pm 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/lib/DateTime/Infinite.pm 2014-05-05 03:26:50.000000000 +0200 @@ -1,5 +1,5 @@ package DateTime::Infinite; -$DateTime::Infinite::VERSION = '1.07'; +$DateTime::Infinite::VERSION = '1.10'; use strict; use warnings; @@ -34,7 +34,7 @@ sub STORABLE_thaw {return} package DateTime::Infinite::Future; -$DateTime::Infinite::Future::VERSION = '1.07'; +$DateTime::Infinite::Future::VERSION = '1.10'; use strict; use warnings; @@ -59,7 +59,7 @@ } package DateTime::Infinite::Past; -$DateTime::Infinite::Past::VERSION = '1.07'; +$DateTime::Infinite::Past::VERSION = '1.10'; use strict; use warnings; @@ -169,7 +169,7 @@ =head1 VERSION -version 1.07 +version 1.10 =head1 SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/lib/DateTime/LeapSecond.pm new/DateTime-1.10/lib/DateTime/LeapSecond.pm --- old/DateTime-1.07/lib/DateTime/LeapSecond.pm 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/lib/DateTime/LeapSecond.pm 2014-05-05 03:26:50.000000000 +0200 @@ -1,5 +1,5 @@ package DateTime::LeapSecond; -$DateTime::LeapSecond::VERSION = '1.07'; +$DateTime::LeapSecond::VERSION = '1.10'; use strict; use warnings; @@ -128,7 +128,7 @@ =head1 VERSION -version 1.07 +version 1.10 =head1 SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/lib/DateTime.pm new/DateTime-1.10/lib/DateTime.pm --- old/DateTime-1.07/lib/DateTime.pm 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/lib/DateTime.pm 2014-05-05 03:26:50.000000000 +0200 @@ -1,16 +1,26 @@ package DateTime; -$DateTime::VERSION = '1.07'; +$DateTime::VERSION = '1.10'; use 5.008001; use strict; use warnings; +use warnings::register; + +use Carp; +use DateTime::Duration; +use DateTime::Helpers; +use DateTime::Locale 0.41; +use DateTime::TimeZone 1.09; +use Params::Validate 0.76 + qw( validate validate_pos UNDEF SCALAR BOOLEAN HASHREF OBJECT ); +use POSIX qw(floor); +use Try::Tiny; { my $loaded = 0; unless ( $ENV{PERL_DATETIME_PP} ) { - local $@; - eval { + try { require XSLoader; XSLoader::load( __PACKAGE__, @@ -19,12 +29,12 @@ : 42 ); + $loaded = 1; $DateTime::IsPurePerl = 0; + } + catch { + die $_ if $_ && $_ !~ /object version|loadable object/; }; - - die $@ if $@ && $@ !~ /object version|loadable object/; - - $loaded = 1 unless $@; } if ($loaded) { @@ -36,16 +46,6 @@ } } -use Carp; -use DateTime::Duration; -use DateTime::Helpers; -use DateTime::Locale 0.41; -use DateTime::TimeZone 1.09; -use Params::Validate 0.76 - qw( validate validate_pos UNDEF SCALAR BOOLEAN HASHREF OBJECT ); -use POSIX qw(floor); -use Try::Tiny; - # for some reason, overloading doesn't work unless fallback is listed # early. # @@ -255,6 +255,8 @@ # adding one to the local year given to the constructor. $self->{utc_year} = $p{year} + 1; + $self->_maybe_future_dst_warning( $p{year}, $p{time_zone} ); + $self->_calc_utc_rd; $self->_handle_offset_modifier( $p{second} ); @@ -530,14 +532,40 @@ my $self = $class->_new( %p, %args, time_zone => 'UTC' ); + my $tz = $p{time_zone}; + $self->_maybe_future_dst_warning( $self->year(), $p{time_zone} ); + $self->set_time_zone( $p{time_zone} ) if exists $p{time_zone}; return $self; } } +sub now { + my $class = shift; + return $class->from_epoch( epoch => $class->_core_time(), @_ ); +} + +sub _maybe_future_dst_warning { + shift; + my $year = shift; + my $tz = shift; + + return unless $year >= 5000 && $tz; + + my $tz_name = ref $tz ? $tz->name() : $tz; + return if $tz_name eq 'floating' || $tz_name eq 'UTC'; + + warnings::warnif( + "You are creating a DateTime object with a far future year ($year) and a time zone ($tz_name)." + . ' If the time zone you specified has future DST changes this will be very slow.' + ); +} + # use scalar time in case someone's loaded Time::Piece -sub now { shift->from_epoch( epoch => ( scalar time ), @_ ) } +sub _core_time { + return scalar time; +} sub today { shift->now(@_)->truncate( to => 'day' ) } @@ -979,20 +1007,20 @@ ( $_[0]->{local_rd_days} * SECONDS_PER_DAY ) + $_[0]->{local_rd_secs}; } -# RD 1 is JD 1,721,424.5 - a simple offset -sub jd { +# RD 1 is MJD 678,576 - a simple offset +sub mjd { my $self = shift; - my $jd = $self->{utc_rd_days} + 1_721_424.5; + my $mjd = $self->{utc_rd_days} - 678_576; my $day_length = $self->_day_length( $self->{utc_rd_days} ); - return ( $jd + return ( $mjd + ( $self->{utc_rd_secs} / $day_length ) + ( $self->{rd_nanosecs} / $day_length / MAX_NANOSECONDS ) ); } -sub mjd { $_[0]->jd - 2_400_000.5 } +sub jd { $_[0]->mjd + 2_400_000.5 } { my %strftime_patterns = ( @@ -1425,8 +1453,7 @@ if ( $bigger->is_dst && do { - local $@; - my $prev_day = eval { $bigger->clone->subtract( days => 1 ) }; + my $prev_day = try { $bigger->clone->subtract( days => 1 ) }; $prev_day && !$prev_day->is_dst ? 1 : 0; } ); @@ -1437,8 +1464,7 @@ if ( !$bigger->is_dst && do { - local $@; - my $prev_day = eval { $bigger->clone->subtract( days => 1 ) }; + my $prev_day = try { $bigger->clone->subtract( days => 1 ) }; $prev_day && $prev_day->is_dst ? 1 : 0; } ); @@ -1985,7 +2011,16 @@ $self->add( days => -1 * $day_diff ); } - return $self->truncate( to => 'day' ); + # This can fail if the truncate ends up giving us an invalid local + # date time. If that happens we need to reverse the addition we + # just did. See https://rt.cpan.org/Ticket/Display.html?id=93347. + try { + $self->truncate( to => 'day' ); + } + catch { + $self->add( days => $day_diff ); + die $_; + }; } else { my $truncate; @@ -2140,7 +2175,7 @@ =head1 VERSION -version 1.07 +version 1.10 =head1 SYNOPSIS @@ -2301,13 +2336,13 @@ If you are going to be using doing date math, please read the section L<How DateTime Math Works>. -=head2 Time Zone Warnings +=head2 Determining the Local Time Zone Can Be Slow -Determining the local time zone for a system can be slow. If C<$ENV{TZ}> is -not set, it may involve reading a number of files in F</etc> or elsewhere. If -you know that the local time zone won't change while your code is running, and -you need to make many objects for the local time zone, it is strongly -recommended that you retrieve the local time zone once and cache it: +If C<$ENV{TZ}> is not set, it may involve reading a number of files in F</etc> +or elsewhere. If you know that the local time zone won't change while your +code is running, and you need to make many objects for the local time zone, it +is strongly recommended that you retrieve the local time zone once and cache +it: our $App::LocalTZ = DateTime::TimeZone->new( name => 'local' ); @@ -2334,6 +2369,22 @@ All constructors can die when invalid parameters are given. +=head3 Warnings + +Currently, constructors will warn if you try to create a far future DateTime +(year >= 5000) with any time zone besides floating or UTC. This can be very +slow if the time zone has future DST transitions that need to be +calculated. If the date is sufficiently far in the future this can be +I<really> slow (minutes). + +All warnings from DateTime use the C<DateTime> category and can be suppressed +with: + + no warnings 'DateTime'; + +This warning may be removed in the future if L<DateTime::TimeZone> is made +much faster. + =head3 DateTime->new( ... ) This class method accepts parameters for each date and time component: @@ -3155,6 +3206,23 @@ DateTime objects can be compared to any other calendar class that implements the C<utc_rd_values()> method. +=head2 Testing Code That Uses DateTime + +If you are trying to test code that calls uses DateTime, you may want to be +able to explicitly set the value returned by Perl's C<time()> builtin. This +builtin is called by C<< DateTime->now() >> and C<< DateTime->today() >>. + +You can override C<CORE::GLOBAL::time()>, but this will only work if you do +this B<before> loading DateTime. If doing this is inconvenient, you can also +override C<DateTime::_core_time()>: + + no warnings 'redefine'; + local *DateTime::_core_time = sub { return 42 }; + +DateTime is guaranteed to core this subroutine to get the current C<time()> +value. You can also override the C<_core_time()> sub in a subclass of DateTime +and use that. + =head2 How DateTime Math Works It's important to have some understanding of how datetime math is diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/16truncate.t new/DateTime-1.10/t/16truncate.t --- old/DateTime-1.07/t/16truncate.t 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/t/16truncate.t 2014-05-05 03:26:50.000000000 +0200 @@ -5,6 +5,7 @@ use Test::More 0.88; use DateTime; +use Try::Tiny; my %vals = ( year => 50, @@ -233,4 +234,41 @@ } } +{ + my $dt = DateTime->new( + year => 2010, + month => 3, + day => 25, + hour => 1, + minute => 5, + time_zone => 'Asia/Tehran', + ); + + is( + $dt->day_of_week(), + 4, + 'day of week is Thursday' + ); + + my $error; + try { + $dt->truncate( to => 'week' ); + } + catch { + $error = $_; + }; + + like( + $error, + qr/Invalid local time for date/, + 'truncate operation threw an error because of an invalid local datetime' + ); + + is( + $dt->day_of_week(), + 4, + 'day of week does not change after failed truncate() call' + ); +} + done_testing(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/45core-time.t new/DateTime-1.10/t/45core-time.t --- old/DateTime-1.07/t/45core-time.t 1970-01-01 01:00:00.000000000 +0100 +++ new/DateTime-1.10/t/45core-time.t 2014-05-05 03:26:50.000000000 +0200 @@ -0,0 +1,19 @@ +use strict; +use warnings; + +use Test::More; + +use DateTime; + +no warnings 'redefine'; +local *DateTime::_core_time = sub { 0 }; + +my $dt = DateTime->now; + +is( + "$dt", + '1970-01-01T00:00:00', + 'overriding DateTime::_core_time() works' +); + +done_testing(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/46warnings.t new/DateTime-1.10/t/46warnings.t --- old/DateTime-1.07/t/46warnings.t 1970-01-01 01:00:00.000000000 +0100 +++ new/DateTime-1.10/t/46warnings.t 2014-05-05 03:26:50.000000000 +0200 @@ -0,0 +1,85 @@ +use strict; +use warnings; + +use Test::More; +use Test::Warnings 0.005 ':all'; + +use DateTime; + +my $year_5001_epoch = 95649120000; + +SKIP: +{ + skip 'These tests require a 64-bit Perl', 2 + unless ( gmtime($year_5001_epoch) )[5] == 3101; + + { + like( + warning { + DateTime->from_epoch( + epoch => $year_5001_epoch, + time_zone => 'Asia/Taipei', + ); + }, + qr{\QYou are creating a DateTime object with a far future year (5001) and a time zone (Asia/Taipei).}, + 'got a warning when calling ->from_epoch with a far future epoch and a time_zone' + ); + } + + { + no warnings 'DateTime'; + is_deeply( + warning { + DateTime->from_epoch( + epoch => $year_5001_epoch, + time_zone => 'Asia/Taipei', + ); + }, + [], + 'no warning when calling ->from_epoch with a far future epoch and a time_zone with DateTime warnings category suppressed' + ); + } +} + +{ + like( + warning { + DateTime->new( + year => 5001, + time_zone => 'Asia/Taipei', + ); + }, + qr{\QYou are creating a DateTime object with a far future year (5001) and a time zone (Asia/Taipei).}, + 'got a warning when calling ->new with a far future year and a time_zone' + ); +} + +{ + no warnings 'DateTime'; + is_deeply( + warning { + DateTime->new( + year => 5001, + time_zone => 'Asia/Taipei', + ); + }, + [], + 'no warning when calling ->new with a far future epoch and a time_zone with DateTime warnings category suppressed' + ); +} + +{ + no warnings; + is_deeply( + warning { + DateTime->new( + year => 5001, + time_zone => 'Asia/Taipei', + ); + }, + [], + 'no warning when calling ->new with a far future epoch and a time_zone with all warnings suppressed' + ); +} + +done_testing(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/release-cpan-changes.t new/DateTime-1.10/t/release-cpan-changes.t --- old/DateTime-1.07/t/release-cpan-changes.t 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/t/release-cpan-changes.t 2014-05-05 03:26:50.000000000 +0200 @@ -8,12 +8,8 @@ } -use strict; -use warnings; - -use Test::More 0.96 tests => 2; -use_ok('Test::CPAN::Changes'); -subtest 'changes_ok' => sub { - changes_file_ok('Changes'); -}; +use Test::More; +eval 'use Test::CPAN::Changes'; +plan skip_all => 'Test::CPAN::Changes required for this test' if $@; +changes_ok(); done_testing(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/release-no-tabs.t new/DateTime-1.10/t/release-no-tabs.t --- old/DateTime-1.07/t/release-no-tabs.t 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/t/release-no-tabs.t 2014-05-05 03:26:50.000000000 +0200 @@ -9,7 +9,7 @@ use strict; use warnings; -# this test was generated with Dist::Zilla::Plugin::NoTabsTests 0.06 +# this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.07 use Test::More 0.88; use Test::NoTabs; @@ -21,7 +21,106 @@ 'lib/DateTime/Infinite.pm', 'lib/DateTime/LeapSecond.pm', 'lib/DateTimePP.pm', - 'lib/DateTimePPExtra.pm' + 'lib/DateTimePPExtra.pm', + 't/00load.t', + 't/01sanity.t', + 't/02last-day.t', + 't/03components.t', + 't/04epoch.t', + 't/05set.t', + 't/06add.t', + 't/07compare.t', + 't/09greg.t', + 't/10subtract.t', + 't/11duration.t', + 't/12week.t', + 't/13strftime.t', + 't/14locale.t', + 't/15jd.t', + 't/16truncate.t', + 't/17set-return.t', + 't/18today.t', + 't/19leap-second.t', + 't/20infinite.t', + 't/21bad-params.t', + 't/22from-doy.t', + 't/23storable.t', + 't/24from-object.t', + 't/25add-subtract.t', + 't/26dt-leapsecond-pm.t', + 't/27delta.t', + 't/28dow.t', + 't/29overload.t', + 't/30future-tz.t', + 't/31formatter.t', + 't/32leap-second2.t', + 't/33seconds-offset.t', + 't/34set-tz.t', + 't/35rd-values.t', + 't/36invalid-local.t', + 't/37local-add.t', + 't/38local-subtract.t', + 't/39no-so.t', + 't/40leap-years.t', + 't/41cldr-format.t', + 't/42duration-class.t', + 't/43new-params.t', + 't/44set-formatter.t', + 't/45core-time.t', + 't/46warnings.t', + 't/author-test-all-my-deps.t', + 't/release-cpan-changes.t', + 't/release-eol.t', + 't/release-load-is-xs.t', + 't/release-no-tabs.t', + 't/release-pod-coverage.t', + 't/release-pod-linkcheck.t', + 't/release-pod-spell.t', + 't/release-pod-syntax.t', + 't/release-pp-00load.t', + 't/release-pp-01sanity.t', + 't/release-pp-02last-day.t', + 't/release-pp-03components.t', + 't/release-pp-04epoch.t', + 't/release-pp-05set.t', + 't/release-pp-06add.t', + 't/release-pp-07compare.t', + 't/release-pp-09greg.t', + 't/release-pp-10subtract.t', + 't/release-pp-11duration.t', + 't/release-pp-12week.t', + 't/release-pp-13strftime.t', + 't/release-pp-14locale.t', + 't/release-pp-15jd.t', + 't/release-pp-16truncate.t', + 't/release-pp-17set-return.t', + 't/release-pp-18today.t', + 't/release-pp-19leap-second.t', + 't/release-pp-20infinite.t', + 't/release-pp-21bad-params.t', + 't/release-pp-22from-doy.t', + 't/release-pp-23storable.t', + 't/release-pp-24from-object.t', + 't/release-pp-25add-subtract.t', + 't/release-pp-27delta.t', + 't/release-pp-28dow.t', + 't/release-pp-29overload.t', + 't/release-pp-30future-tz.t', + 't/release-pp-31formatter.t', + 't/release-pp-32leap-second2.t', + 't/release-pp-33seconds-offset.t', + 't/release-pp-34set-tz.t', + 't/release-pp-35rd-values.t', + 't/release-pp-36invalid-local.t', + 't/release-pp-37local-add.t', + 't/release-pp-38local-subtract.t', + 't/release-pp-40leap-years.t', + 't/release-pp-41cldr-format.t', + 't/release-pp-42duration-class.t', + 't/release-pp-43new-params.t', + 't/release-pp-44set-formatter.t', + 't/release-pp-45core-time.t', + 't/release-pp-46warnings.t' ); notabs_ok($_) foreach @files; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/release-pod-syntax.t new/DateTime-1.10/t/release-pod-syntax.t --- old/DateTime-1.07/t/release-pod-syntax.t 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/t/release-pod-syntax.t 2014-05-05 03:26:50.000000000 +0200 @@ -9,8 +9,6 @@ # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; - -eval "use Test::Pod 1.41"; -plan skip_all => "Test::Pod 1.41 required for testing POD" if $@; +use Test::Pod 1.41; all_pod_files_ok(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/release-pp-16truncate.t new/DateTime-1.10/t/release-pp-16truncate.t --- old/DateTime-1.07/t/release-pp-16truncate.t 2014-02-07 03:35:20.000000000 +0100 +++ new/DateTime-1.10/t/release-pp-16truncate.t 2014-05-05 03:26:50.000000000 +0200 @@ -17,6 +17,7 @@ use Test::More 0.88; use DateTime; +use Try::Tiny; my %vals = ( year => 50, @@ -245,5 +246,42 @@ } } +{ + my $dt = DateTime->new( + year => 2010, + month => 3, + day => 25, + hour => 1, + minute => 5, + time_zone => 'Asia/Tehran', + ); + + is( + $dt->day_of_week(), + 4, + 'day of week is Thursday' + ); + + my $error; + try { + $dt->truncate( to => 'week' ); + } + catch { + $error = $_; + }; + + like( + $error, + qr/Invalid local time for date/, + 'truncate operation threw an error because of an invalid local datetime' + ); + + is( + $dt->day_of_week(), + 4, + 'day of week does not change after failed truncate() call' + ); +} + done_testing(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/release-pp-45core-time.t new/DateTime-1.10/t/release-pp-45core-time.t --- old/DateTime-1.07/t/release-pp-45core-time.t 1970-01-01 01:00:00.000000000 +0100 +++ new/DateTime-1.10/t/release-pp-45core-time.t 2014-05-05 03:26:50.000000000 +0200 @@ -0,0 +1,32 @@ + + +use Test::More; + +BEGIN { + unless ( $ENV{RELEASE_TESTING} ) { + plan skip_all => 'these tests are for testing by the release'; + } + + $ENV{PERL_DATETIME_PP} = 1; +} + +use strict; +use warnings; + +use Test::More; + +use DateTime; + +no warnings 'redefine'; +local *DateTime::_core_time = sub { 0 }; + +my $dt = DateTime->now; + +is( + "$dt", + '1970-01-01T00:00:00', + 'overriding DateTime::_core_time() works' +); + +done_testing(); + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/DateTime-1.07/t/release-pp-46warnings.t new/DateTime-1.10/t/release-pp-46warnings.t --- old/DateTime-1.07/t/release-pp-46warnings.t 1970-01-01 01:00:00.000000000 +0100 +++ new/DateTime-1.10/t/release-pp-46warnings.t 2014-05-05 03:26:50.000000000 +0200 @@ -0,0 +1,98 @@ + + +use Test::More; + +BEGIN { + unless ( $ENV{RELEASE_TESTING} ) { + plan skip_all => 'these tests are for testing by the release'; + } + + $ENV{PERL_DATETIME_PP} = 1; +} + +use strict; +use warnings; + +use Test::More; +use Test::Warnings 0.005 ':all'; + +use DateTime; + +my $year_5001_epoch = 95649120000; + +SKIP: +{ + skip 'These tests require a 64-bit Perl', 2 + unless ( gmtime($year_5001_epoch) )[5] == 3101; + + { + like( + warning { + DateTime->from_epoch( + epoch => $year_5001_epoch, + time_zone => 'Asia/Taipei', + ); + }, + qr{\QYou are creating a DateTime object with a far future year (5001) and a time zone (Asia/Taipei).}, + 'got a warning when calling ->from_epoch with a far future epoch and a time_zone' + ); + } + + { + no warnings 'DateTime'; + is_deeply( + warning { + DateTime->from_epoch( + epoch => $year_5001_epoch, + time_zone => 'Asia/Taipei', + ); + }, + [], + 'no warning when calling ->from_epoch with a far future epoch and a time_zone with DateTime warnings category suppressed' + ); + } +} + +{ + like( + warning { + DateTime->new( + year => 5001, + time_zone => 'Asia/Taipei', + ); + }, + qr{\QYou are creating a DateTime object with a far future year (5001) and a time zone (Asia/Taipei).}, + 'got a warning when calling ->new with a far future year and a time_zone' + ); +} + +{ + no warnings 'DateTime'; + is_deeply( + warning { + DateTime->new( + year => 5001, + time_zone => 'Asia/Taipei', + ); + }, + [], + 'no warning when calling ->new with a far future epoch and a time_zone with DateTime warnings category suppressed' + ); +} + +{ + no warnings; + is_deeply( + warning { + DateTime->new( + year => 5001, + time_zone => 'Asia/Taipei', + ); + }, + [], + 'no warning when calling ->new with a far future epoch and a time_zone with all warnings suppressed' + ); +} + +done_testing(); + -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org
participants (1)
-
root@hilbert.suse.de