NAME

DateTimeX::Lite::TimeZone::Local - Determine the local system's time zone

SYNOPSIS

my $tz = DateTimeX::Lite::TimeZone->load( name => 'local' );

my $tz = DateTimeX::Lite::TimeZone::Local->TimeZone();

DESCRIPTION

This module provides an interface for determining the local system's time zone. Most of the functionality for doing this is in OS-specific subclasses.

USAGE

This class provides the following methods:

DateTimeX::Lite::TimeZone::Local->TimeZone()

This attempts to load an appropriate subclass and asks it to find the local time zone. This method is called by when you pass "local" as the time zone name to DateTime:TimeZone->load().

If an appropriate subclass does not exist, we fall back to using the Unix subclass.

See DateTimeX::Lite::TimeZone::Local::Unix, DateTimeX::Lite::TimeZone::Local::Win32, and DateTimeX::Lite::TimeZone::Local::VMS for OS-specific details.

SUBCLASSING

If you want to make a new OS-specific subclass, there are several methods provided by this module you should know about.

$class->Methods()

This method should be provided by your class. It should provide a list of methods that will be called to try to determine the local time zone.

Each of these methods is expected to return a new DateTimeX::Lite::TimeZone object if it determines the time zone.

$class->FromEnv()

This method tries to find a valid time zone in an %ENV value. It calls $class->EnvVars() to determine which keys to look at.

To use this from a subclass, simply return "FromEnv" as one of the items from $class->Methods().

$class->EnvVars()

This method should be provided by your subclass. It should return a list of env vars to be checked by $class->FromEnv().

$class->_IsValidName($name)

Given a possible time zone name, this returns a boolean indicating whether or not the the name looks valid. It always return false for "local" in order to avoid infinite loops.

EXAMPLE SUBCLASS

Here is a simple example subclass:

package DateTimeX::Lite::TimeZone::SomeOS;

use strict;
use warnings;

use base 'DateTimeX::Lite::TimeZone::Local';


sub Methods { qw( FromEnv FromEther ) }

sub EnvVars { qw( TZ ZONE ) }

sub FromEther
{
    my $class = shift;

    ...
}

AUTHOR

Dave Rolsky, <autarch@urth.org>

COPYRIGHT & LICENSE

Copyright (c) 2003-2008 David Rolsky. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.