[PBP-pm] Working with dates

Joshua Hoblitt jhoblitt at ifa.hawaii.edu
Wed Dec 21 15:48:27 PST 2005


On Wed, Dec 21, 2005 at 06:54:28PM +0000, Bennett Todd wrote:
> For external representations, I really like ISO 8601 / RFC 3339,
> like 2005-12-21T18:50:14Z.
> 
> For many sorts of interval calculations, I'm quite happy using
> time_t (integer seconds since 1970-01-01T00:00:00Z in a POSIX
> fantasy world where leap seconds don't exist), converting printable
> => time_t with Date::Parse (from TimeDate), and back with
> Date::Format (likewise) if I need Date::Parse, POSIX::strftime if
> not.

I'd be hesitant to suggest using POSIX.pm is a 'Best Practice' as it
sucks up 900K-1500K of memory depending on the platform.

I'd also like to point out that DateTime natively support an ISO8601
compliant format. e.g.

    my $dt = DateTime->now;
    print $dt->iso8601;

There is also a module called DateTime::Format::IS08601 that parses a
wide range of IS08601:2000(E) formats. 

    my $dt = DateTime::Format::ISO8601->parse_datetime( $string );

(Note: I am the author of DateTIme::Format::ISO8601)

It's not that I have anything against using 'Duct Tape' solutions, it's
just that in this particular instance using one is no longer required.

Cheers,

-J

--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/pbp-pm/attachments/20051221/6b9bd0c3/attachment.bin


More information about the PBP-pm mailing list