|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.