Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DateTime CPAN distribution.

Report information
The Basics
Id: 40555
Status: resolved
Priority: 0/
Queue: DateTime

People
Owner: Nobody in particular
Requestors: wilson [...] xyber.ph
Cc:
AdminCc:

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



Subject: DateTime->format_cldr( 'yy' )
Date: Fri, 31 Oct 2008 16:01:57 +0800
To: bug-DateTime [...] rt.cpan.org
From: "Wilson Santos" <wilson [...] xyber.ph>
DateTime->format_cldr( 'yy' ) does not properly produce a 2-digit year for years whose 3rd digit is 0 (e.g. 2008). use DateTime; $dt = DateTime->new( year => 2008, month => 10, day => 16, hour => 16, minute => 12, ); print $dt->format_cldr( 'yy' ); # should return '08' - Distribution name and version (For example, "DBIx-SearchBuilder-0.46") <http://search.cpan.org/%7Edrolsky/DateTime-0.4305/> DateTime-0.4305 - Perl version (Find this by running the command perl -v) This is perl, v5.8.6 built for darwin-thread-multi-2level (with 4 registered patches, see perl -V for more detail) - Operating System vendor and version (Find this by running the command uname -a) Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh powerpc - A patch against the latest released version of this distribution which fixes this bug. This replaces the hardcoded '2' in the parameter passed to _zero_padded_number --- old/DateTime.pm 2008-10-31 15:36:52.000000000 +0800 +++ new/DateTime.pm 2008-10-31 15:31:03.000000000 +0800 @@ -1011,7 +1011,7 @@ # yy is a weird special case, where it must be exactly 2 digits qr/yy/ => sub { my $year = $_[0]->year(); $year = substr( $year, -2, 2 ) if length $year > 2; - $_[0]->_zero_padded_number( 2, $year ) }, + $_[0]->_zero_padded_number( $year, $year ) }, qr/y/ => sub { $_[0]->year() }, qr/(u+)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->year() ) }, qr/(Y+)/ => sub { $_[0]->_zero_padded_number( $1, $_[0]->week_year() ) }, thanks -- Wilson Santos Xybersolutions 4th Floor, Mobile Entertainment Centre 104 Rada St., Legaspi Village Makati City 1229