Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime-Format-Strptime CPAN distribution.

Report information
The Basics
Id: 73893
Status: resolved
Priority: 0/
Queue: DateTime-Format-Strptime

People
Owner: Nobody in particular
Requestors: se456 [...] rohan.id.au
Cc:
AdminCc:

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



Subject: DateTime::Format::Strptime bug parsing 4 digit years using %y
Date: Wed, 11 Jan 2012 16:24:35 +0800
To: bug-DateTime-Format-Strptime [...] rt.cpan.org
From: Rohan Carly <se456 [...] rohan.id.au>
Hi, I think I may have discovered a bug in DateTime::Format::Strptime. I am using version 1.5000. It seems to me that 4 digit years are parsed incorrectly, when you specify %y in the format string. My interpretation of the docs is that %y should be able to handle both 2 digit and 4 digit years. Here is my test code: #!/usr/bin/perl -w use DateTime::Format::Strptime; my $Strp = new DateTime::Format::Strptime( pattern => '%d %m %y', ); my $in; $in = '1 3 2011'; my $dt; $dt = $Strp->parse_datetime($in); my $epoch; $epoch = $dt->epoch; print gmtime($epoch)."\n"; # prints Sun Mar 1 00:00:00 2020 # but I expected Tue Mar 1 00:00:00 2011 From the docs: # From man DateTime::Format::Strptime # %y # # The year within century (0-99). When a century is not otherwise # specified, values in the range 69-99 refer to years in the # twentieth century (1969-1999); values in the range 00-68 refer to # years in the twenty-first century (2000-2068). # # %Y # # The year, including century (for example, 1991). Let me know if I am misunderstanding something. Thanks, Rohan.
On Wed Jan 11 03:24:53 2012, se456@rohan.id.au wrote: Show quoted text
> Hi, I think I may have discovered a bug in DateTime::Format::Strptime. > I am > using version 1.5000. > > It seems to me that 4 digit years are parsed incorrectly, when you > specify %y > in the format string. My interpretation of the docs is that %y should > be able > to handle both 2 digit and 4 digit years. > > Here is my test code: > > #!/usr/bin/perl -w > > use DateTime::Format::Strptime; > > my $Strp = new DateTime::Format::Strptime( > pattern => '%d %m %y', > ); > > my $in; > $in = '1 3 2011'; > > my $dt; > $dt = $Strp->parse_datetime($in); > > my $epoch; > $epoch = $dt->epoch; > > print gmtime($epoch)."\n"; > > # prints Sun Mar 1 00:00:00 2020 > # but I expected Tue Mar 1 00:00:00 2011 > > From the docs: > # From man DateTime::Format::Strptime > # %y > # > # The year within century (0-99). When a century is not > otherwise > # specified, values in the range 69-99 refer to years in > the > # twentieth century (1969-1999); values in the range 00-68 > refer to > # years in the twenty-first century (2000-2068). > # > # %Y > # > # The year, including century (for example, 1991). > > > Let me know if I am misunderstanding something. > > Thanks, > > Rohan.
The docs are a little confusing, but the reference to specifying a century is referring the %C format.