use strict;
use warnings;
use Data::Dumper;
use DateTime;
use Time::ParseDate;
use DateTime::TimeZone;
our %TIMEZONES = (
# DST
'-3.5Y' => 'America/St_Johns',
'-4Y' => 'America/Halifax',
'-5Y' => 'America/New_York',
'-6Y' => 'America/Chicago',
'-7Y' => 'America/Denver',
'-8Y' => 'America/Los_Angeles',
'-9Y' => 'America/Anchorage',
'-10Y' => 'America/Adak',
# NOT DST
'-11N' => 'Pacific/Midway',
'-10N' => 'Pacific/Honolulu',
'-8N' => 'Pacific/Pitcairn',
'-7N' => 'America/Phoenix',
'-6N' => 'America/Managua',
'-4N' => 'America/St_Vincent',
'0N' => 'America/Danmarkshavn',
'9N' => 'Pacific/Palau',
'10N' => 'Pacific/Truk',
'11N' => 'Pacific/Efate',
'12N' => 'Pacific/Wallis',
);
sub timezone {
my ($utc_offset,$is_dst) = @_;
return DateTime::TimeZone->new( name => $TIMEZONES{$utc_offset . $is_dst} );
}
my $input = '11:50:45.242 EDT OCT 27 2015';
my $epoch = parsedate( $input );
my $dt = DateTime->from_epoch( epoch => $epoch );
$dt->set_time_zone( timezone( 0, 'N' ) );
print $dt->strftime( '%Y-%m-%d %H:%M:%S' ), $/;
####
$dt->set_time_zone( timezone( 0, 'N' ) );
##
##
$dt->set_time_zone( timezone( -5, 'Y' ) ); # Central with DST
$dt->set_time_zone( timezone( -6, 'N' ) ); # Eastern without DST
$dt->set_time_zone( timezone( -6, 'Y' ) ); # Eastern with DST
##
##