Skip Menu |

This queue is for tickets about the Time-Piece CPAN distribution.

Report information
The Basics
Id: 1777
Status: resolved
Priority: 0/
Queue: Time-Piece

People
Owner: Nobody in particular
Requestors: tony [...] tmtm.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: Bug with strptime/strftime
use Time::Piece; my $tp = Time::Piece->strptime("2002-01-01", "%Y-%m-%d"); printf "%s = %s = %s\n", $tp, $tp->strftime, $tp->strftime("%A"); This prints: Use of uninitialized value in subroutine entry at /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. Use of uninitialized value in subroutine entry at /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. Use of uninitialized value in subroutine entry at /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. Use of uninitialized value in subroutine entry at /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. Use of uninitialized value in subroutine entry at /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. Use of uninitialized value in subroutine entry at /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. Tue Jan 1 00:00:00 2002 = Sun, 01 Jan 2002 00:00:00 GMT = Sunday A Tuesday has become a Sunday ... which is not good... Tony
From: Dave Rolsky <autarch [...] urth.org>
[TMTM - Sat Nov 9 04:02:30 2002]: Show quoted text
> use Time::Piece; > > my $tp = Time::Piece->strptime("2002-01-01", "%Y-%m-%d"); > > printf "%s = %s = %s\n", $tp, $tp->strftime, $tp->strftime("%A"); > > > This prints: > > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Tue Jan 1 00:00:00 2002 = Sun, 01 Jan 2002 00:00:00 GMT = Sunday > > A Tuesday has become a Sunday ... which is not good...
This is the same bug as #1297, for which I submitted a patch (in the bug report) 4 months ago. Matt, _please_ release a new version. This is a pretty serious bug.
Date: Mon, 25 Nov 2002 07:46:36 +0000
Subject: Re: [cpan #1777] Bug with strptime/strftime
From: Matt Sergeant <matt [...] sergeant.org>
To: bug-Time-Piece [...] rt.cpan.org
RT-Send-Cc:
Show quoted text
> This is the same bug as #1297, for which I submitted a patch (in the > bug > report) 4 months ago. Matt, _please_ release a new version. This is a > pretty serious bug.
Sorry :-( The patch applies cleanly, but the test fails: not ok 84 # Test 84 got: '5' (t/02core.t at line 167) # Expected: '4' not ok 85 # Test 85 got: '4' (t/02core.t at line 168) # Expected: '3' This is on Mac OS X, where strptime/strftime are a bit screwed up (and internally implemented in the XS code). I'll give it a go on other platforms, but do let me know if you have any ideas why the above might happen.
From: autarch [...] urth.org
[matt@sergeant.org - Mon Nov 25 02:47:11 2002]: Show quoted text
> > This is the same bug as #1297, for which I submitted a patch (in the > > bug > > report) 4 months ago. Matt, _please_ release a new version. This is a > > pretty serious bug.
> > Sorry :-( > > The patch applies cleanly, but the test fails: > > not ok 84 > # Test 84 got: '5' (t/02core.t at line 167) > # Expected: '4' > not ok 85 > # Test 85 got: '4' (t/02core.t at line 168) > # Expected: '3' > > This is on Mac OS X, where strptime/strftime are a bit screwed up (and > internally implemented in the XS code). I'll give it a go on other > platforms, but do let me know if you have any ideas why the above might > happen.
RT didn't send me mail when you replied to this. Please CC me so I can get it. Anyway, it looks like on OS X it uses the strptime function that you wrote yourself, so my assumption would that something in that code is wrong ;) The two tests that are failing rely on tm->tm_wday being set correctly in strptime(). It looks like it's being set one day ahead of what it should be set at. But it's definitely not a bug in my patch. The tests that are failing are simply checking that 2002/07/10 returns 4 for the wday function and 3 for the day_of_week function. Since that day was a Wednesday, the expected values are correct.
Date: Sun, 22 Dec 2002 10:39:07 +0000
Subject: Re: [cpan #1777] Bug with strptime/strftime
Cc: autarch [...] urth.org
To: bug-Time-Piece [...] rt.cpan.org
From: Matt Sergeant <matt [...] sergeant.org>
RT-Send-Cc:
On Sunday, Dec 22, 2002, at 05:44 Europe/London, Guest via RT wrote: Show quoted text
> RT didn't send me mail when you replied to this. Please CC me so I can > get it.
Hopefully you'll get this assuming I've remembered your email address right ;-) Show quoted text
> Anyway, it looks like on OS X it uses the strptime function that you > wrote yourself, so my assumption would that something in that code is > wrong ;)
Well I copied it from elsewhere, and unfortunately it looks like the version I've copied is the same version as Jaguar uses now - when I remove my version it still errors in the same way. I think basically the problem is it needs to fill in the blanks - but the OSX strptime doesn't do that. My guess is that POSIX doesn't require that. Show quoted text
> The two tests that are failing rely on tm->tm_wday being set correctly > in strptime(). It looks like it's being set one day ahead of what it > should be set at. But it's definitely not a bug in my patch. The > tests > that are failing are simply checking that 2002/07/10 returns 4 for the > wday function and 3 for the day_of_week function. Since that day was a > Wednesday, the expected values are correct.
OK, I guess I'll have to look into how I normalise the time then. I guess I can probably pass it through timegm then gmtime... I'll see if that fixes it.
Date: Sun, 22 Dec 2002 10:57:00 +0000
Subject: Re: [cpan #1777] Bug with strptime/strftime
From: Matt Sergeant <matt [...] sergeant.org>
To: bug-Time-Piece [...] rt.cpan.org
RT-Send-Cc:
OK. fixed in CVS. The problem was that my_mini_mktime only tried to fix wday under certain circumstances. So I just made it always do it.
[TMTM - Sat Nov 9 04:02:30 2002]: Show quoted text
> use Time::Piece; > > my $tp = Time::Piece->strptime("2002-01-01", "%Y-%m-%d"); > > printf "%s = %s = %s\n", $tp, $tp->strftime, $tp->strftime("%A"); > > > This prints: > > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Use of uninitialized value in subroutine entry at > /usr/local/lib/perl/5.8.0/Time/Piece.pm line 397. > Tue Jan 1 00:00:00 2002 = Sun, 01 Jan 2002 00:00:00 GMT = Sunday > > A Tuesday has become a Sunday ... which is not good...
Seems to work ok in CVS on Mac OS X. Marking resolved. Re-open if this is not the case.