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

People
Owner: Nobody in particular
Requestors: PHILKIME [...] cpan.org
Cc:
AdminCc:

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



It seems that it's impossible to instantiate an object with missing information even when it's allowed by the format. Using DateTime::Format::ISO8601 I can instantiate ->new('2003') which is allowed by ISO8601 but then DateTime applies a default month and ->month gives "01" so it's impossible to distinguish whether the date passed was "2003" or "2003-01-01", for example. I would have expected ->month to return "undef" for the former but it defaults to "01" and I can't find a way to prevent this. Seems the same also in every other date module I have tried.
Subject: Re: [rt.cpan.org #63380]
Date: Sat, 27 Nov 2010 15:03:01 +0100
To: bug-DateTime [...] rt.cpan.org, datetime [...] perl.org
From: "Flavio S. Glock" <fglock [...] gmail.com>
2010/11/27 Philip Kime via RT <bug-DateTime@rt.cpan.org>: Show quoted text
> > It seems that it's impossible to instantiate an object with missing information even when it's > allowed by the format. Using DateTime::Format::ISO8601 I can instantiate > > ->new('2003') > > which is allowed by ISO8601 but then DateTime applies a default month and > > ->month > > gives "01" > > so it's impossible to distinguish whether the date passed was "2003" or  "2003-01-01", for > example. I would have expected ->month to return "undef" for the former but it defaults to "01" > and I can't find a way to prevent this. Seems the same also in every other date module I have > tried.
Have you looked at DateTime::Incomplete? http://search.cpan.org/dist/DateTime-Incomplete/lib/DateTime/Incomplete.pm Flávio S. Glock