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(-)

Reply via email to