diff options
author | Samuel Smith <esaym@cpan.org> | 2020-04-09 14:58:56 -0400 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2020-04-09 15:06:12 -0400 |
commit | a5ebaea1256879b6be6776f2cf8be0a2f3ae2579 (patch) | |
tree | 32c3ab975eda5bc9acd6c3295a36de771b4df406 | |
parent | 31fa749cfc50ff7f2bde2237bf6da5547efd53d4 (diff) | |
download | perl-a5ebaea1256879b6be6776f2cf8be0a2f3ae2579.tar.gz |
Time-Piece: synch with CPAN version 1.3401
From Changes:
1.3401 2020-04-06
- Add tests for negative and large epochs
- Remove %I tests from 09locales.t
- Exempt more tests unless $ENV{AUTOMATED_TESTING}
- Safeguards around 12-hour time notation
1.34 2020-02-27
- Exempt DST tests unless $ENV{AUTOMATED_TESTING}
- Add recent test files to MANIFEST (openstrike)
Committer: Time-Piece maintainer is now a Perl author
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | MANIFEST | 1 | ||||
-rwxr-xr-x | Porting/Maintainers.pl | 2 | ||||
-rw-r--r-- | cpan/Time-Piece/Piece.pm | 14 | ||||
-rw-r--r-- | cpan/Time-Piece/Seconds.pm | 2 | ||||
-rw-r--r-- | cpan/Time-Piece/t/06large.t | 42 | ||||
-rw-r--r-- | cpan/Time-Piece/t/09locales.t | 28 |
7 files changed, 73 insertions, 17 deletions
@@ -1115,6 +1115,7 @@ Salvador Ortiz Garcia <sog@msg.com.mx> Sam Kimbrel <kimbrel@me.com> Sam Tregar <sam@tregar.com> Sam Vilain <sam@vilain.net> +Samuel Smith <esaym@cpan.org> Samuel Thibault <sthibault@debian.org> Samuli Kärkkäinen <skarkkai@woods.iki.fi> Santtu Ojanperä <santtuojanpera98@gmail.com> @@ -2598,6 +2598,7 @@ cpan/Time-Piece/t/02core_dst.t cpan/Time-Piece/t/03compare.t Test for Time::Piece cpan/Time-Piece/t/04mjd.t Test for Time::Piece cpan/Time-Piece/t/05overload.t Test for Time::Piece +cpan/Time-Piece/t/06large.t cpan/Time-Piece/t/06subclass.t Test for Time::Piece cpan/Time-Piece/t/07arith.t Test for Time::Piece cpan/Time-Piece/t/08truncate.t diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index b49667d9b9..79efda53f7 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -1189,7 +1189,7 @@ use File::Glob qw(:case); }, 'Time::Piece' => { - 'DISTRIBUTION' => 'ESAYM/Time-Piece-1.34.tar.gz', + 'DISTRIBUTION' => 'ESAYM/Time-Piece-1.3401.tar.gz', 'FILES' => q[cpan/Time-Piece], 'EXCLUDED' => [ qw[reverse_deps.txt] ], }, diff --git a/cpan/Time-Piece/Piece.pm b/cpan/Time-Piece/Piece.pm index 7a61370e21..f5d87cd031 100644 --- a/cpan/Time-Piece/Piece.pm +++ b/cpan/Time-Piece/Piece.pm @@ -19,7 +19,7 @@ our %EXPORT_TAGS = ( ':override' => 'internal', ); -our $VERSION = '1.34'; +our $VERSION = '1.3401'; XSLoader::load( 'Time::Piece', $VERSION ); @@ -126,7 +126,7 @@ sub _mktime { if ($class->_is_time_struct($time)) { my @new_time = @$time; my @tm_parts = (@new_time[c_sec .. c_mon], $new_time[c_year]+1900); - #TODO: what happens here for data below 1970? + $new_time[c_epoch] = $islocal ? timelocal(@tm_parts) : timegm(@tm_parts); return wantarray ? @new_time : bless [@new_time[0..9], $islocal], $class; @@ -806,8 +806,14 @@ sub use_locale { #get locale month/day names from posix strftime (from Piece.xs) my $locales = _get_localization(); - $locales->{PM} ||= ''; - $locales->{AM} ||= ''; + #If AM and PM are the same, set both to '' + if ( !$locales->{PM} + || !$locales->{AM} + || ( $locales->{PM} eq $locales->{AM} ) ) + { + $locales->{PM} = ''; + $locales->{AM} = ''; + } $locales->{pm} = lc $locales->{PM}; $locales->{am} = lc $locales->{AM}; diff --git a/cpan/Time-Piece/Seconds.pm b/cpan/Time-Piece/Seconds.pm index fda1d2fbcc..6aa864d97e 100644 --- a/cpan/Time-Piece/Seconds.pm +++ b/cpan/Time-Piece/Seconds.pm @@ -1,7 +1,7 @@ package Time::Seconds; use strict; -our $VERSION = '1.34'; +our $VERSION = '1.3401'; use Exporter 5.57 'import'; diff --git a/cpan/Time-Piece/t/06large.t b/cpan/Time-Piece/t/06large.t new file mode 100644 index 0000000000..aa0c192f8b --- /dev/null +++ b/cpan/Time-Piece/t/06large.t @@ -0,0 +1,42 @@ +use Test::More; +use Time::Piece; +use Time::Seconds; + +# Large tests - test dates outside of the epoch range, +# somewhat silly, but lets see what happens + + +plan skip_all => "Large time tests not required for installation" + unless ( $ENV{AUTOMATED_TESTING} ); + +TODO: { + local $TODO = "Big dates will probably fail on some platforms"; + my $t = gmtime; + + my $base_year = $t->year; + my $one_year = ONE_YEAR; + + for ( 1 .. 50 ) { + $t = $t + $one_year; + cmp_ok( + $t->year, '==', + $base_year + $_, + "Year is: " . ( $base_year + $_ ) + ); + } + + $t = gmtime; + $base_year = $t->year; + + for ( 1 .. 200 ) { + $t = $t - $one_year; + cmp_ok( + $t->year, '==', + $base_year - $_, + "Year is: " . ( $base_year - $_ ) + ); + } + +} + +done_testing(250); diff --git a/cpan/Time-Piece/t/09locales.t b/cpan/Time-Piece/t/09locales.t index e7c183f37d..b1d031646c 100644 --- a/cpan/Time-Piece/t/09locales.t +++ b/cpan/Time-Piece/t/09locales.t @@ -1,6 +1,11 @@ -use Test::More tests => 172; +use Test::More; use Time::Piece; +# Skip if doing a regular install +# These are mostly for reverse parsing tests, not required for installation +plan skip_all => "Reverse parsing not required for installation" + unless ( $ENV{AUTOMATED_TESTING} ); + my $t = gmtime(1373371631); # 2013-07-09T12:07:11 #locale should be undef @@ -24,6 +29,10 @@ $t->day_list(@frdays); cmp_ok( $t->day, 'eq', &Time::Piece::_locale()->{wday}[ $t->_wday ] ); cmp_ok( $t->fullday, 'eq', &Time::Piece::_locale()->{weekday}[ $t->_wday ] ); + +#load local locale +Time::Piece->use_locale(); + #test reverse parsing sub check_parsed { @@ -53,18 +62,16 @@ my @dates = ( #TODO # '%u %U %Y %T', #%U,W,V currently skipped inside strptime # '%w %W %y %T', - '%A, %e %B %Y at %I:%M:%S %p', #%I and %p can be locale dependant - '%x %X', #hard coded to American localization +# '%A, %e %B %Y at %I:%M:%S %p', #%I and %p can be locale dependant + '%x %X', #hard coded to American localization ); for my $time ( - time(), # Now, whenever that might be - 1451606400, # 2016-01-01 00:00 - 1451649600, # 2016-01-01 12:00 + time(), # Now, whenever that might be + 1451606400, # 2016-01-01 00:00 + 1451649600, # 2016-01-01 12:00 ) { - Time::Piece->use_locale(); - local $ENV{LC_TIME} = 'en_US'; # Otherwise DD/MM vs MM/DD causes grief my $t = gmtime($time); for my $strp_format (@dates) { @@ -86,8 +93,6 @@ for my $time ( 1451649600, # 2016-01-01 12:00 ) { - Time::Piece->use_locale(); - local $ENV{LC_TIME} = 'en_US'; # Otherwise DD/MM vs MM/DD causes grief my $t = localtime($time); for my $strp_format (@dates) { @@ -95,7 +100,7 @@ for my $time ( my $parsed; SKIP: { eval { $parsed = $t->strptime( $t_str, $strp_format ); }; - skip "gmtime strptime parse failed", 3 if $@; + skip "localtime strptime parse failed", 3 if $@; check_parsed( $t, $parsed, $t_str, $strp_format ); } @@ -103,3 +108,4 @@ for my $time ( } +done_testing(154); |