Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Though Date::Manip is certainly able to do this kind of operations, I would not recommand using it. In fact neither the author of this module:
Is Date::Manip the one you should be using? In my opinion, the answer is no about 90% of the time. This sounds odd coming from the author of the software, but read on.
Date::Manip is written entirely in perl. It's the most powerful of the date modules. It's also the biggest and slowest.

There are plenty of specialized module in the Date::* hierarchy that can fill the bill. For instance, I would use Time::Local for this kind of job, but I'm sure one could find a better suited module (maybe Date::Format?). Anyway here's a stab at it:

use Time::Local; my $time1 = '010101112245'; my $time2 = '010101114556'; foreach ($time1, $time2){ my @t = $time1 =~ /(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/; @t = reverse @t; $_ = timelocal(@t); } print "Difference is: ", ($time1 -$time2), "\n";

Disclaimer: Code barely tested, not to be used to operate nuclear reactors.

<kbd>--
my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>

In reply to Re: parsing date string by OeufMayo
in thread parsing date string by adonai

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (22)
    As of 2014-07-11 17:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (232 votes), past polls