The string time zone seems to be an issue ...

#!perl use warnings; use strict; use Carp; use Time::Piece; $SIG{__WARN__} = sub { Carp::cluck @_; }; $SIG{__DIE__} = sub { Carp::confess @_; }; $| = 1; my $format_notz = "%a, %d %b %Y %T"; my $format_tz_name = "${format_notz} %Z"; my $format_tz_offset = "${format_notz} %z"; my $time = 'Wed, 13 Jan 2021 17:00:00'; my %time_map = ( $time => $format_notz, qq[$time CST] => $format_tz_name, qq[$time -0600] => $format_tz_offset, ); for my $t ( sort keys %time_map ) { my $format = $time_map{ $t }; my $tp = Time::Piece->strptime( $t, $format ); printf "%s\n -> %s ->\n", $t, $format; printf " %s\n\n", $tp->strftime( $format ); } __END__ Wed, 13 Jan 2021 17:00:00 -> %a, %d %b %Y %T -> Wed, 13 Jan 2021 17:00:00 Wed, 13 Jan 2021 17:00:00 -0600 -> %a, %d %b %Y %T %z -> Wed, 13 Jan 2021 23:00:00 +0000 Error parsing time at C:/Users/parv/mine--no-backup/strawberry-perl-5. +32.0.1-64bit-portable/perl/lib/Time/Piece.pm line 598. at x-timepc.pl line 9. main::__ANON__("Error parsing time at C:/Users/parv/mine--no-b +ackup/strawberr"...) called at C:/Users/parv/mine--no-backup/strawber +ry-perl-5.32.0.1-64bit-portable/perl/lib/Time/Piece.pm line 598 Time::Piece::strptime("Time::Piece", "Wed, 13 Jan 2021 17:00:0 +0 CST", "%a, %d %b %Y %T %Z") called at x-timepc.pl line 26

FreeBSD man strftime.


In reply to Re: Question regarding Time::Piece and timezones by parv
in thread Question regarding Time::Piece and timezones by atcroft

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.