Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Time::Piece epoch parsing

by runrig (Abbot)
on Jul 01, 2016 at 15:26 UTC ( [id://1167005]=note: print w/replies, xml ) Need Help??


in reply to Time::Piece epoch parsing

My man pages say that %e is the same as %d, i.e., the day of the month.(Update: I need glasses...OP is %s not %e) That said, you don't have to 'parse' an epoch, you just pass it to new():
use strict; use warnings; use Time::Piece; my $e = time(); my $t = Time::Piece->new($e); print Time::Piece->VERSION, "\n"; print "Input $e\n"; print "Output ".$t->epoch(), "\n"; print $t, "\n"; print $t->strftime, "\n";

Replies are listed 'Best First'.
Re^2: Time::Piece epoch parsing
by vsespb (Chaplain) on Jul 03, 2016 at 23:47 UTC
    I am not looking for way to parse epoch, I am investigating why strptime with %s works wrong.
      I am not looking for way to parse epoch, I am investigating why strptime with %s works wrong.
      Um, strptime is a function that (I think) is short for string-parse-time, and %s is the field descriptor for epoch, so I think you are trying to parse an epoch, whether you realize it or not.

        There's a small but important distinction, though. He is not trying to parse, he is parsing[*]. Elsewhere, the problem lies.

        No, I actually have a function which accepts strptime-like-format and data to parse and parses it. So I need strptime functionality and other ways to parse epoch are useless to me.

      I am not looking for way to parse epoch, I am investigating why strptime with %s works wrong.

      Look at the source, IIRC its a call to the underling C Runtimes strptime function, they're not all the same

        *it's. Also, sentences end with a dot.

        Time::Piece includes its own version of strptime(); there is no call to libc function. This embedded C function returns a got_GMT value which, however, is simply discarded. A value of 0 is always returned to perl side, corresponding with the islocal flag. One end of the module does not know or care what the other end is doing....

Log In?
Username:
Password:

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

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

    No recent polls found