Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Help sorting dates

by Anonymous Monk
on May 29, 2010 at 16:16 UTC ( [id://842192]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a report that timestamps events like so:

Fri 11:43 PM -- if it occurred in a previous day

or

2:11 AM, if it occurred during the current day.

These events can have multiple timestamps for various comments, status, etc.

I want a way to parse the reports so that I see only events with the most recent time stamps. So I need a way to convert the two aforementioned formats into a common one, and do a comparison. Any tips?

Replies are listed 'Best First'.
Re: Help sorting dates
by choroba (Cardinal) on May 29, 2010 at 16:38 UTC
Re: Help sorting dates
by bradcathey (Prior) on May 30, 2010 at 14:36 UTC

    When you say "timestamp," can imply that these are going in a database? If so, lots of built-in SQL functions.

    If not, ignore.

    FWIW, I use Date::Calc

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re: Help sorting dates
by bluescreen (Friar) on May 30, 2010 at 15:09 UTC
    You can create your own Date/Time manipulation module, and overload the >, <, =, >=, !=, <= functions, if you want to work with dates in an OO way, so you could do something like:
    if ( $timestamp1 > $timestamp2 ) ..or.. if ($timestamp1 == $timestamp2 ) ..and so on..

    I've something like that implemented at work, using Date::Calc as backend of our date manipulation module, Date::Calc its flexible and fast.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2024-04-23 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found