in reply to Converting MySQL datetime values to DateTime objects

DateTime::Format::MySQL should be able to do this. From the manpage:
my $dt = DateTime::Format::MySQL->parse_datetime( '2003-01-16 23:12:01 +' );
There's also a parse_date() and a parse_timestamp() method.

In general, if you really find something missing from a module, try contacting the author of that module first. You say you can write the function you want; send him that for inclusion in the next version of the module. Writing your own module just for that small bit of functionality you're missing should only be your last solution, when all else fails.

For datetime modules you can also send your ideas, additions and patches to the datetime@perl.org mailing list. They can help you to get your code in the correct DateTime module or to write your own DateTime module.

Replies are listed 'Best First'.
Re: Converting MySQL datetime values to DateTime objects
by jonadab (Parson) on Jul 14, 2003 at 21:47 UTC

    ++

    I didn't see it because I was looking at DateTime::Format::DBI as a wrapper around DateTime::Format::MySQL and DateTime::Format::Pg, one that I assumed would wrap all their functionality, but the documentation for DateTime::Format::DBI doesn't mention any parse functions. DateTime::Format::MySQL::parse_datetime will do exactly what I wanted. Thanks!


    Quidquid latine dictum sit altum viditur.