Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Using Time::Piece Strptime

by stevieb (Canon)
on Jan 26, 2016 at 01:43 UTC ( [id://1153629]=note: print w/replies, xml ) Need Help??


in reply to Re: Using Time::Piece Strptime
in thread Using Time::Piece Strptime

Don't assume the input. I think it's more important to show that the return is an object, and that the output can be whatever manipulation one wants :)

The object will print out a date if it didn't fail, so the input is clearly legit in this case. OP just needs to know how to dump it properly.

Replies are listed 'Best First'.
Re^3: Using Time::Piece Strptime
by 1nickt (Canon) on Jan 26, 2016 at 01:58 UTC

    ??

    The code I posted shows how to get the desired output specified in the OP.

    It also addresses the input pattern issue, since I believe it is unlikely that the input data is actually like 3/11/16, 00, Mar, 2016 and that it's more likely the OP made an error with his pattern that his input data masked.

    Update: reply to (unmarked) addition above:

    "The object will print out a date if it didn't fail, so the input is clearly legit in this case. OP just needs to know how to dump it properly."

    Actually I would say it's rather important to get the right parsed datetime, not simply that "the object ... didn't fail." It's not the input that's at issue, it's the pattern used to parse the input.


    The way forward always starts with a minimal test.
      We won't know unless OP provides input data. I'm always up to learning, and being corrected.

      You could use regexpression

      #!/usr/bin/perl -w use Time::Piece; use strict; my $date = '3/11/16, 00, Mar, 2016'; Time::Piece->strptime($date, '%D, %M, %b, %Y') =~ /^(.+)\d\d:\d\d:\d\d + (.+)$/ ; my $date1 =join ' ',$1,$2; print "$date1\n";

Log In?
Username:
Password:

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

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

    No recent polls found