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: 58459
Status: resolved
Priority: 0/
Queue: DateTime-Format-Strptime

People
Owner: Nobody in particular
Requestors: alex [...] chmrr.net
Cc:
AdminCc:

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



X-Message-Linecount: 79
X-Spam-Flag: NO
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Date: 2010-06-16 13:27:34
X-Spam-Score: -9.906
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id CED4E2408F6 for <cpan-bug+datetime-format-strptime [...] hipster.bestpractical.com>; Wed, 16 Jun 2010 13:26:35 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zzFAv28Bpb52 for <cpan-bug+datetime-format-strptime [...] hipster.bestpractical.com>; Wed, 16 Jun 2010 13:26:34 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id C128A24088B for <bug-datetime-format-strptime [...] rt.cpan.org>; Wed, 16 Jun 2010 13:26:33 -0400 (EDT)
Received: (qmail 14186 invoked by uid 103); 16 Jun 2010 17:27:39 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 16 Jun 2010 17:27:39 -0000
Received: from chmrr.net (HELO utwig.chmrr.net) (209.67.253.66) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Wed, 16 Jun 2010 10:27:36 -0700
Received: from 75-147-59-54-newengland.hfc.comcastbusiness.net ([75.147.59.54] helo=localhost.localdomain) by utwig.chmrr.net with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.71) (envelope-from <alex [...] chmrr.net>) id 1OOwOg-0006i5-I8 for bug-datetime-format-strptime [...] rt.cpan.org; Wed, 16 Jun 2010 13:27:34 -0400
Delivered-To: cpan-bug+datetime-format-strptime [...] hipster.bestpractical.com
Subject: [PATCH] '%e' and friends can include a leading space, which DateTime objects to
X-Local-Recipient-Count: 1
X-Body-Size: 2533
X-Body-Linecount: 72
X-Spam-Check-BY: 16.mx.develooper.com
Date: Wed, 16 Jun 2010 13:27:21 -0400
X-Spam-Level:
To: bug-datetime-format-strptime [...] rt.cpan.org
X-Authenticator: plain
X-Received-Count: 1
From alex [...] chmrr.net Wed Jun 16 13: 26:35 2010
X-Spam-Status: No, score=-9.906 tagged_above=-99.9 required=10 tests=[BAYES_00=-2.599, RCVD_IN_DNSWL_HI=-8, SPF_FAIL=0.693] autolearn=ham
X-Local-Recipient-Defer-Count: 0
X-Mailer: git-send-email 1.7.0.4
Message-ID: <1276709241-19581-1-git-send-email-alex [...] chmrr.net>
X-Connected-Ip: 75.147.59.54:37633
X-Recipient-Count: 1
Return-Path: <alex [...] chmrr.net>
X-Original-To: cpan-bug+datetime-format-strptime [...] hipster.bestpractical.com
X-RT-Mail-Extension: datetime-format-strptime
X-Local-Recipient-Fail-Count: 0
X-Authenticated-User: chmrr
X-Sender-Verify: SUCCEEDED (sender exists & accepts mail)
X-Message-Size: 2839
X-Exim-Version: 4.71 (build at 26-Feb-2010 17:03:13)
From: Alex Vandiver <alex [...] chmrr.net>
X-RT-Original-Encoding: ascii
content-type: text/plain; charset="utf-8"
Content-Length: 2533
Download (untitled) / with headers
text/plain 2.4k
When parsing, '%e' accepts a leading space; however, when ' 3' is passed as an argument to DateTime->new, it fails. Resolve this by forcing the arguemnts to DateTime->new to be purely numeric, by adding 0. --- lib/DateTime/Format/Strptime.pm | 18 +++++++++--------- t/002_dates.t | 6 +++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/DateTime/Format/Strptime.pm b/lib/DateTime/Format/Strptime.pm index fcf1700..1e4a2fc 100644 --- a/lib/DateTime/Format/Strptime.pm +++ b/lib/DateTime/Format/Strptime.pm @@ -542,7 +542,7 @@ iso_week_year_100 = $iso_week_year_100 and return undef unless $Year and $Month; my $dt = eval { - DateTime->new( year => $Year, month => $Month, day => $Day, + DateTime->new( year => $Year+0, month => $Month+0, day => $Day+0, hour => 12, time_zone => $use_timezone ); }; $self->local_croak("Datetime $Year-$Month-$Day is not a valid date") @@ -646,14 +646,14 @@ iso_week_year_100 = $iso_week_year_100 my $potential_return = eval { DateTime->new( - year => ( $Year || 1 ), - month => ( $Month || 1 ), - day => ( $Day || 1 ), - - hour => ( $Hour || 0 ), - minute => ( $Minute || 0 ), - second => ( $Second || 0 ), - nanosecond => ( $Nanosecond || 0 ), + year => ( $Year || 1 )+0, + month => ( $Month || 1 )+0, + day => ( $Day || 1 )+0, + + hour => ( $Hour || 0 )+0, + minute => ( $Minute || 0 )+0, + second => ( $Second || 0 )+0, + nanosecond => ( $Nanosecond || 0 )+0, locale => $self->{_locale}, time_zone => $use_timezone, diff --git a/t/002_dates.t b/t/002_dates.t index e15fda3..f1c1e03 100644 --- a/t/002_dates.t +++ b/t/002_dates.t @@ -2,7 +2,7 @@ # t/002_basic.t - check module dates in various formats -use Test::More tests => 17; +use Test::More tests => 19; use DateTime::Format::Strptime; use DateTime; use DateTime::TimeZone; @@ -36,6 +36,10 @@ my @tests = ( # Complex dates [ '%Y;%j = %Y-%m-%d', '2003;56 = 2003-02-25' ], [ q|%d %b '%y = %Y-%m-%d|, q|25 Feb '03 = 2003-02-25| ], + + # Leading spaces + [ '%e-%b-%Y %T %z', '13-Jun-2010 09:20:47 -0400' ], + [ '%e-%b-%Y %T %z', ' 3-Jun-2010 09:20:47 -0400' ], ); foreach (@tests) { -- 1.7.0.4
MIME-Version: 1.0
In-Reply-To: <1276709241-19581-1-git-send-email-alex [...] chmrr.net>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <1276709241-19581-1-git-send-email-alex [...] chmrr.net>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2217-1281187216-1216.58459-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 267
Download (untitled) / with headers
text/plain 267b
It seems the author doesn't check RT... I cross-posted this. http://code.google.com/p/datetime-format-strptime/issues/detail?id=27 -- If riding in an airplane is flying, then riding in a boat is swimming. 116 jumps, 48.6 minutes of freefall, 92.9 freefall miles.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.