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
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>
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
- '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] ],
},
':override' => 'internal',
);
':override' => 'internal',
);
+our $VERSION = '1.3401';
XSLoader::load( 'Time::Piece', $VERSION );
XSLoader::load( 'Time::Piece', $VERSION );
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;
#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};
package Time::Seconds;
use strict;
package Time::Seconds;
use strict;
+our $VERSION = '1.3401';
use Exporter 5.57 'import';
use Exporter 5.57 'import';
--- /dev/null
+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);
-use Test::More tests => 172;
+# 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
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
{
#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
- 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) {
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) {
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 );
}