Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: problems parsing Time/Date strings

by frozenwithjoy (Priest)
on Jul 08, 2012 at 21:29 UTC ( [id://980626]=note: print w/replies, xml ) Need Help??


in reply to Re^2: problems parsing Time/Date strings
in thread problems parsing Time/Date strings

I would definitely recommend DateTime. It is well done and actively maintained. You can set your locale or use time_zone => 'floating' to ignore time zones. I would also take a look at the slides from Dave Rolsky's DateTime talk (video here). They are handy for understanding why weird things happen with date math.

Replies are listed 'Best First'.
Re^4: problems parsing Time/Date strings
by Anonymous Monk on Aug 04, 2012 at 08:13 UTC

    Thanks for the links !

    I totally agree about the slide comment regarding DateTime::Duration

    Luckily DateTime::Format::Human::Duration works around that

    #!/usr/bin/perl -- use strict; use warnings; use DateTime::Duration; use DateTime::Format::Human::Duration; use DateTime::Format::Natural; @ARGV = ( "last week", "today" ) unless @ARGV; my $dfn = DateTime::Format::Natural->new; my $start = $dfn->parse_datetime(shift); my $end = $dfn->parse_datetime(shift); my $diff = $end - $start; print "$end - $start = ", DateTime::Format::Human::Duration->new->format_duration($diff), "\n" +; __END__ 2012-08-04T00:00:00 - 2012-07-28T00:00:00 = 1 week

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://980626]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2024-04-18 13:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found