I was able to obtain this list myself just by making use of DateTime and
DateTime::TimeZone. Code here for anyone interested:
+++
#!perl
# Generate lists of timezones sorted alphabetically and by offset

 use DateTime;
 use DateTime::TimeZone;

 my $names = DateTime::TimeZone->new(name => 'America/Chicago');
 my @valid = $names->all_names;
 my $i = 0;

 $timelist = time();
 my ($sec, $min, $hour, $day, $nmonth, $year, $wday, $day_of_year,
$isdst) = localtime($timelist);

 $nmonth = $nmonth + 1;

 $year += 1900;

 local @zone_array;

 for ($i=0;$i<=$#valid;$i++) {
   my $zone = DateTime::TimeZone->new( name => $valid[$i] );
   my $dt = DateTime->new(year=>$year, month=>$nmonth,day=>$day,
                            hour=>$hour,minute=>$min,
                            time_zone => $valid[$i]);

   my $offset = $zone->offset_for_datetime($dt);

# List timezones alphabetically with offset in seconds
   print "$valid[$i] $offset\n";

   $zone_array[$i] = ($dt->strftime("%z") . " " . $valid[$i] . "\n");
 }

# List timezones numerically by offset, display in hours offset
 @sorted_zone_array = sort (@zone_array);
   print "\n\n";
 print ("@sorted_zone_array\n");

 exit(0);
+++


Rick Brewer wrote:

Can someone provide a reference to a list of timezones and their offsets? I recall seeing such a list that was sorted by offset recently but cannot locate it now.

thanks,
Rick





Reply via email to