This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Time-Piece: synch with CPAN version 1.3401
authorSamuel Smith <esaym@cpan.org>
Thu, 9 Apr 2020 18:58:56 +0000 (14:58 -0400)
committerJames E Keenan <jkeenan@cpan.org>
Thu, 9 Apr 2020 19:06:12 +0000 (15:06 -0400)
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

AUTHORS
MANIFEST
Porting/Maintainers.pl
cpan/Time-Piece/Piece.pm
cpan/Time-Piece/Seconds.pm
cpan/Time-Piece/t/06large.t [new file with mode: 0644]
cpan/Time-Piece/t/09locales.t

diff --git a/AUTHORS b/AUTHORS
index 0c45b44..a5d6550 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -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>
 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>
 Samuel Thibault                <sthibault@debian.org>
 Samuli Kärkkäinen              <skarkkai@woods.iki.fi>
 Santtu Ojanperä                <santtuojanpera98@gmail.com>
index 11203ce..3f2f670 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -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/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
 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
index b49667d..79efda5 100755 (executable)
@@ -1189,7 +1189,7 @@ use File::Glob qw(:case);
     },
 
     'Time::Piece' => {
     },
 
     '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] ],
     },
         'FILES'        => q[cpan/Time-Piece],
         'EXCLUDED'     => [ qw[reverse_deps.txt] ],
     },
index 7a61370..f5d87cd 100644 (file)
@@ -19,7 +19,7 @@ our %EXPORT_TAGS = (
     ':override' => 'internal',
     );
 
     ':override' => 'internal',
     );
 
-our $VERSION = '1.34';
+our $VERSION = '1.3401';
 
 XSLoader::load( 'Time::Piece', $VERSION );
 
 
 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);
     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;
         $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();
 
     #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};
 
     $locales->{pm} = lc $locales->{PM};
     $locales->{am} = lc $locales->{AM};
index fda1d2f..6aa864d 100644 (file)
@@ -1,7 +1,7 @@
 package Time::Seconds;
 use strict;
 
 package Time::Seconds;
 use strict;
 
-our $VERSION = '1.34';
+our $VERSION = '1.3401';
 
 use Exporter 5.57 'import';
 
 
 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 (file)
index 0000000..aa0c192
--- /dev/null
@@ -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);
index e7c183f..b1d0316 100644 (file)
@@ -1,6 +1,11 @@
-use Test::More tests => 172;
+use Test::More;
 use Time::Piece;
 
 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
 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 ] );
 
 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
 {
 #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',
 #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 (
 );
 
 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) {
 
     my $t = gmtime($time);
     for my $strp_format (@dates) {
 
@@ -86,8 +93,6 @@ for my $time (
     1451649600,    # 2016-01-01 12: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 = localtime($time);
     for my $strp_format (@dates) {
 
     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 ); };
         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 );
         }
 
             check_parsed( $t, $parsed, $t_str, $strp_format );
         }
 
@@ -103,3 +108,4 @@ for my $time (
 
 }
 
 
 }
 
+done_testing(154);