#! /usr/bin/perl

use strict;
use Time::Local;

sub timezone {
    # Return local time zone in numeric form.
    # In summer, some windows machines in some time zones may
    # believe you use daylight savings time when you don't.
    # This is an MS C library bug. See Microsoft KB article Q148681.
    
    my $isdst = (localtime)[-1];
    my $offset  = sprintf "%.1f", (timegm(localtime) - time) / 3600;
    my $minutes = sprintf "%02d", abs( $offset - int($offset) ) * 60;
    my $tz = sprintf("%+03d", int($offset)) . $minutes;
    return wantarray ? ($tz, $isdst) : $tz;
}

my $zone = timezone;

print "In scalar context, timezone returns '$zone'\n",
      "In list context, it adds a flag for daylight savings time: ( ",
      join(', ', timezone), " )\n";
