I remember we've discussed
Time::Piece and timezones here. I can't find it anymore (maybe most of it was ChatterBox), but I took two lessons from it:
- If you want the object to know about timezones, use localtime (see below);
- If you want to work with timezones, don't use Time::Piece.
#! /usr/bin/perl
use strict;
use warnings;
use feature qw{ say };
use Time::Piece;
my $pattern = "%a, %d %b %Y %T";
my $str = 'Wed, 13 Jan 2021 17:22:23';
local $ENV{TZ} = 'CST';
my $u1 = Time::Piece->strptime($str, $pattern);
my $u2 = localtime($u1);
say $_->strftime('%F %T %Z') for $u1, $u2;
__END__
2021-01-13 17:22:23 UTC
2021-01-13 17:22:23 CST
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]