Seems to me that "2003" isn't a datetime, nor is "2003-05-01", both are spans. 
2003 = '2003-01-01 00:00:00.0' - '2004-01-01 00:00:00.0'

Maybe there's something that can be done with DT:Incomplete given that change 
in perspective?

Maybe DT:F:Strptime could return a DT:Incomplete as an 'error' option. 

No solutions, just thoughts. 

Cheers!
Rick Measham


On 24/02/2011, at 17:59, Philip Kime <philk...@kime.org.uk> wrote:

> Yes, that would be fine and I could use DateTime::Incomplete to get
> what I want but unfortunately what I need is the parsing so I don't
> have to parse it all myself (which is what I'm currently doing). The
> strings aren't that simple I'm afraid, that was just a minimal
> example. In fact, the strings are so irregular in one app data source
> driver that I really need to use DataTime::Format::Natural ...
> 
> PK
> 
> On 24 February 2011 01:34, Karen Etheridge <p...@froods.org> wrote:
>> On Wed, Feb 23, 2011 at 09:23:08PM +0100, Philip Kime wrote:
>>> All I really want is to be able to say:
>>> 
>>> $dt = DateTime::Format::Somemodule->new('2008');
>>> 
>>> and have $dt->month and $dt->day return undef instead of "1" otherwise I 
>>> can't distinguish from:
>>> 
>>> $dt = DateTime::Format::Somemodule->new('2008-01-01');
>>> 
>>> Even DateTime::Format::ISO8601 doesn't do this even though "2008" is a 
>>> valid ISO8601 date.
>> 
>> If your strings really are this simple, could you not simply do $dt =
>> DateTime->new(year => 2008);  ?  The DateTime::Format::* modules are simply
>> string parsers which call DateTime->new with various arguments -- there is
>> no reason why you can't call the constructor yourself.
>> 
>> 
>> 
>> --
>>                     "The 3 great virtues of a programmer:
>>                Laziness, Impatience, and Hubris." - Larry Wall
>>            .             .            .            .             .
>> Karen Etheridge, ka...@etheridge.ca       GCS C+++$ USL+++$ P+++$ w--- M++
>> http://etheridge.ca/                      PS++ PE-- b++ DI++++ e++ h(-)
>> 
> 
> 
> 
> -- 
> Dr Philip Kime
> -- 
> Message  protected for iSite by MailGuard: e-mail anti-virus, anti-spam and 
> content filtering.http://www.mailguard.com.au
> Click here to report this message as spam:
> https://login.mailguard.com.au/report/1BMjZLkebE/36DtTOMZrBA6cRxeViXzr4/0
> 
-- 
Message  protected for iSite by MailGuard: e-mail anti-virus, anti-spam and 
content filtering.http://www.mailguard.com.au

Reply via email to