in reply to Re^7: Converting local time to utc time
in thread Converting local time to utc time

The change forward is not a problem, it's moving back that creates the ambiguity. As I see it you need to delay applying the UTC timezone until the second sequence of 01:00 to 01:59 times on the change day. I suggest using the is_DST method to detect the change, and a hash to remember when the time repeats. For example :

#!perl use DateTime; use DateTime::TimeZone; use strict; my %seen=(); my $tz = 'UTC'; my $last; while (<DATA>){ chomp; next unless ($_); my ($y,$m,$d,$hr,$min) = split /\D/,$_; print "$_ : "; my $dt = DateTime->new ( year => $y, month => $m, day => $d, hour => $hr, minute => $min, time_zone => 'Europe/London', ); print $dt->is_dst," : "; if ($m==10 && $hr==1){ if ($dt->is_dst() ne $last){ $tz = '-1:00'; } $tz = 'UTC' if ++$seen{$min} > 1; } else { %seen=(); } $last = $dt->is_dst(); $dt->set_time_zone($tz); print $dt->strftime("%Y-%m-%d %H:%M")," $tz \n"; } __DATA__ 2014-03-30 00:59 2014-03-30 02:00 2014-03-30 02:01 2014-03-30 02:30 2014-03-30 02:59 2014-03-30 03:00 2014-03-30 03:01 2014-03-30 03:30 2014-03-30 03:59 2014-03-30 04:00 2014-03-30 04:01 2014-03-30 04:02 2014-10-26 00:59 2014-10-26 01:00 2014-10-26 01:01 2014-10-26 01:30 2014-10-26 01:59 2014-10-26 01:00 2014-10-26 01:01 2014-10-26 01:30 2014-10-26 01:59 2014-10-26 02:00 2014-10-26 02:01 2014-10-26 02:02