NAME

    DateTime::TimeZone::Local::Win32 - Determine the local system's time
    zone on Windows

VERSION

    version 2.10

SYNOPSIS

      my $tz = DateTime::TimeZone->new( name => 'local' );
    
      my $tz = DateTime::TimeZone::Local->TimeZone();

DESCRIPTION

    This module provides methods for determining the local time zone on a
    Windows platform.

REQUIREMENTS

    This module is used by DateTime::TimeZone, which lists it as a
    prerequisite on Windows, so it is installed with DateTime::TimeZone. It
    does not list DateTime::TimeZone as a prerequisite, because that would
    be circular: install DateTime (which installs DateTime::TimeZone) to
    use it. Until DateTime is installed, the tests that need it are
    skipped.

HOW THE TIME ZONE IS DETERMINED

    This class tries the following methods of determining the local time
    zone:

      * $ENV{TZ}

      It checks $ENV{TZ}. A time zone name that DateTime::TimeZone accepts
      is used. Anything else, such as a POSIX rule string like
      CET-1CEST,M3.5.0,M10.5.0/3, is ignored and the registry is used.

      * Windows Registry

      When using the registry, we look for the Windows time zone and use a
      mapping to translate this to an IANA time zone name.

	* Windows Vista, 2008 Server and newer Windows operating systems

	We read the value TimeZoneKeyName in
	"SYSTEM/CurrentControlSet/Control/TimeZoneInformation/". If it is
	set, we use it to look up the IANA time zone name in our mapping.
	On Windows 2008 Server the value has extra data after a null
	character, which we remove.

	* Windows NT, Windows 2000, Windows XP, Windows 2003 Server

	We look in "SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time
	Zones/" and loop through all of its sub keys.

	For each sub key, we compare its Std value with the value
	StandardName in
	"SYSTEM/CurrentControlSet/Control/TimeZoneInformation/". The sub
	key that matches gives us the English name of the Windows time
	zone, which we use to look up the IANA time zone name.

	On Windows Vista and newer without TimeZoneKeyName, StandardName is
	a resource string such as "@tzres.dll,-112", so we compare it with
	each sub key's MUI_Std value as well.

	* Windows 95, Windows 98, Windows Millennium Edition

	The algorithm is the same as for NT, but we loop through the sub
	keys of "SOFTWARE/Microsoft/Windows/CurrentVersion/Time Zones/"

    The name of the returned time zone can differ from the name in our
    mapping, because DateTime::TimeZone resolves links. For example,
    Greenland Standard Time maps to America/Godthab, and DateTime::TimeZone
    2.39 and newer name that time zone America/Nuuk. Windows time zones
    that are a fixed offset, such as Dateline Standard Time, have an offset
    as their name, such as -1200.

IF THE TIME ZONE CANNOT BE DETERMINED

    If Windows is set to a time zone that this module does not know, or
    whose IANA time zone the installed DateTime::TimeZone cannot load, the
    lookup dies with a message that starts with "Cannot determine local
    time zone", names the Windows time zone, and says what to upgrade. This
    usually means Windows has a time zone that is newer than this module or
    than DateTime::TimeZone. To see which Windows time zone this machine is
    set to:

      reg query "HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" /v TimeZoneKeyName

    If the message does not name a Windows time zone, this module may have
    failed to load; this command shows why:

      perl -MDateTime::TimeZone::Local::Win32 -e1

    If you cannot upgrade yet, name the time zone in your program. Either
    pass an IANA name instead of "local":

      my $tz = DateTime::TimeZone->new( name => 'America/New_York' );

    or set TZ only while the local time zone is looked up. TZ is checked
    before the registry:

      my $tz = do {
          local $ENV{TZ} = 'America/New_York';
          DateTime::TimeZone->new( name => 'local' );
      };

    Do not set TZ to an IANA name for the whole machine or in a Command
    Prompt. The Windows C runtime reads TZ in its own format (such as
    EST5EDT) and does not understand IANA names, so Perl's own localtime,
    and other programs started from that prompt, show the wrong time.

AUTHORS

      * David Pinkowitz <dapink_cpan@pinkowitz.com>

      * Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE

    Copyright (C) 2007-2014 Dave Rolsky <autarch@urth.org> Copyright (C)
    2014-2026 by David Pinkowitz <dapink_cpan@pinkowitz.com>

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

