Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.

In reply to Re: Time::Piece->strptime formatting throws: Error parsing time . . . (split %Z) by Anonymous Monk
in thread Time::Piece->strptime formatting throws: Error parsing time . . . by hesco

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

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

    No recent polls found