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