Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Time::Piece epoch parsing

by runrig (Abbot)
on Jul 01, 2016 at 15:26 UTC ( #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
Node Status?
node history
Node Type: note [id://1167005]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2019-04-19 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (106 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!