I've been trying to implement the OP's application using your suggestions. I did get DateTime and DateTime::Format::Strptime installed.
However I seem to be doing something stupid as I can't get to square #1 - creating the $strp object (error shown below).
I would appreciate your help in correcting my error. I am also curious as to what happens with these ambiguous local times, like in the US 1:23 AM can occur twice during the same day. Almost all my work is in GMT/UTC so I don't often work with local time myself.
use strict;
use warnings;
use 5.010;
use DateTime;
use DateTime::Format::Strptime;
$|=1;
my $str = 'Wed, 13 Jan 2021 17:22:23';
my $pattern = '%a, %d %b %Y %T';
my $strp = DateTime::Format::Strptime->new(
pattern => $pattern,
time_zone => 'CST',
zone_map => { CST => '-0700', EST => '-0600' }
);
say "I got this far (not!)";
my $dt = $strp->parse_datetime( $str );
say "String: $str";
say "DateTime: $dt";
say '';
__END__
Invalid offset: CST
Update: BTW, there are all kind of "weirdo" time zones in the world time zones. Also occasionally a specific location can change its time zone - the International Date Line was moved some years back - this affected some islands in the Pacific. |