diff options
author | Spider Boardman <spider@orb.nashua.nh.us> | 1999-09-23 13:54:53 -0400 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-09-24 05:05:06 +0000 |
commit | 33c0e3ec3c9b4103fd0146ace1e9048f01c2013d (patch) | |
tree | 7efbb764c1f46ffe3c82535aeab7acab063e8c58 /t/lib | |
parent | 17f4a12df9ef6ee2f0a77e96071b3f12999159f0 (diff) | |
download | perl-33c0e3ec3c9b4103fd0146ace1e9048f01c2013d.tar.gz |
normalize time for strftime() (without the isdst effects of
mktime()) using a custom mini_mktime()
Message-Id: <199909232154.RAA25151@leggy.zk3.dec.com>
Subject: Re: [ID 19990913.003] Possible bug using POSIX::strftime Digital UNIX Perl 5.005_03
p4raw-id: //depot/perl@4223
Diffstat (limited to 't/lib')
-rwxr-xr-x | t/lib/posix.t | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/t/lib/posix.t b/t/lib/posix.t index 4c6aa49a05..7fb5f62177 100755 --- a/t/lib/posix.t +++ b/t/lib/posix.t @@ -14,7 +14,7 @@ use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write); use strict subs; $| = 1; -print "1..18\n"; +print "1..26\n"; $Is_W32 = $^O eq 'MSWin32'; @@ -95,6 +95,31 @@ print &POSIX::acos(1.0) == 0.0 ? "ok 17\n" : "not ok 17\n"; # See ext/POSIX/hints/sunos_4.pl and ext/POSIX/hints/linux.pl print POSIX::strftime("ok 18 # %H:%M, on %D\n", localtime()); +# If that worked, validate the mini_mktime() routine's normalisation of +# input fields to strftime(). +sub try_strftime { + my $num = shift; + my $expect = shift; + my $got = POSIX::strftime("%a %b %d %H:%M:%S %Y %j", @_); + if ($got eq $expect) { + print "ok $num\n"; + } + else { + print "# expected: $expect\n# got: $got\nnot ok $num\n"; + } +} + +$lc = &POSIX::setlocale(&POSIX::LC_TIME, 'C') if $Config{d_setlocale}; +try_strftime(19, "Wed Feb 28 00:00:00 1996 059", 0,0,0, 28,1,96); +try_strftime(20, "Thu Feb 29 00:00:60 1996 060", 60,0,-24, 30,1,96); +try_strftime(21, "Fri Mar 01 00:00:00 1996 061", 0,0,-24, 31,1,96); +try_strftime(22, "Sun Feb 28 00:00:00 1999 059", 0,0,0, 28,1,99); +try_strftime(23, "Mon Mar 01 00:00:00 1999 060", 0,0,24, 28,1,99); +try_strftime(24, "Mon Feb 28 00:00:00 2000 059", 0,0,0, 28,1,100); +try_strftime(25, "Tue Feb 29 00:00:00 2000 060", 0,0,0, 0,2,100); +try_strftime(26, "Wed Mar 01 00:00:00 2000 061", 0,0,0, 1,2,100); +&POSIX::setlocale(&POSIX::LC_TIME, $lc) if $Config{d_setlocale}; + $| = 0; # The following line assumes buffered output, which may be not true with EMX: print '@#!*$@(!@#$' unless ($^O eq 'os2' || $^O eq 'uwin' || $^O eq 'os390'); |