Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Time::Piece->strptime formatting throws: Error parsing time . . . (split %Z)

by Anonymous Monk
on Sep 24, 2014 at 00:44 UTC ( [id://1101727]=note: print w/replies, xml ) Need Help??


in reply to Time::Piece->strptime formatting throws: Error parsing time . . .

yeah, strftime/strptime isn't identically portable ... I've always had issue with %Z on win32 ... but DateTime's strftime/strptime is portable

#!/usr/bin/perl -- use strict; use warnings; use Time::Piece; my $dt = 'Fri, 20 Sep 2024 01:14:03 UTC'; my $format = '%a, %d %b %Y %T %Z'; #~ print Time::Piece->strptime( $dt, $format ); my @date = split ' ', $dt; my @format = split ' ', $format; for my $ix ( 0 .. $#date ){ print "$ix ## ", "$date[$ix] == $format[$ix]\n"; print "$ix ## ", eval { Time::Piece->strptime( $date[$ix], $format[$ix] ); } || $@, "\n"; } exit; __END__ 0 ## Fri, == %a, 0 ## Thu Jan 1 00:00:00 1970 1 ## 20 == %d 1 ## Tue Jan 20 00:00:00 1970 2 ## Sep == %b 2 ## Tue Sep 1 00:00:00 1970 3 ## 2024 == %Y 3 ## Mon Jan 1 00:00:00 2024 4 ## 01:14:03 == %T 4 ## Thu Jan 1 01:14:03 1970 5 ## UTC == %Z 5 ## Error parsing time at C:/citrusperl/site/lib/Time/Piece.pm +line 469.
  • Comment on Re: Time::Piece->strptime formatting throws: Error parsing time . . . (split %Z)
  • Download Code

Log In?
Username:
Password:

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

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

    No recent polls found