1DateTime::TimeZone::LocUasle(r3)Contributed Perl DocumenDtaatteiToinme::TimeZone::Local(3)
2
3
4
6 DateTime::TimeZone::Local - Determine the local system's time zone
7
9 my $tz = DateTime::TimeZone->new( name => 'local' );
10
11 my $tz = DateTime::TimeZone::Local->TimeZone();
12
14 This module provides an interface for determining the local system's
15 time zone. Most of the functionality for doing this is in OS-specific
16 subclasses.
17
19 This class provides the following methods:
20
21 DateTime::TimeZone::Locale->TimeZone()
22
23 This attempts to load an appropriate subclass and asks it to find the
24 local time zone. This method is called by when you pass "local" as the
25 time zone name to "DateTime:TimeZone->new()".
26
27 If an appropriate subclass does not exist, we fall back to using the
28 Unix subclass.
29
30 See DateTime::TimeZone::Local::Unix, DateTime::TimeZone::Local::Win32,
31 and DateTime::TimeZone::Local::VMS for OS-specific details.
32
34 If you want to make a new OS-specific subclass, there are several meth‐
35 ods provided by this module you should know about.
36
37 $class->Methods()
38
39 This method should be provided by your class. It should provide a list
40 of methods that will be called to try to determine the local time zone.
41
42 Each of these methods is expected to return a new "DateTime::TimeZone"
43 object if it determines the time zone.
44
45 $class->FromEnv()
46
47 This method tries to find a valid time zone in an %ENV value. It calls
48 "$class->EnvVars()" to determine which keys to look at.
49
50 To use this from a subclass, simply return "FromEnv" as one of the
51 items from "$class->Methods()".
52
53 $class->EnvVars()
54
55 This method should be provided by your subclass. It should return a
56 list of env vars to be checked by "$class->FromEnv()".
57
58 $class->_IsValidName($name)
59
60 Given a possible time zone name, this returns a boolean indicating
61 whether or not the the name looks valid. It always return false for
62 "local" in order to avoid infinite loops.
63
65 Here is a simple example subclass:
66
67 package DateTime::TimeZone::SomeOS;
68
69 use strict;
70 use warnings;
71
72 use base 'DateTime::TimeZone::Local';
73
74 sub Methods { qw( FromEnv FromEther ) }
75
76 sub EnvVars { qw( TZ ZONE ) }
77
78 sub FromEther
79 {
80 my $class = shift;
81
82 ...
83 }
84
86 Dave Rolsky, <autarch@urth.org>
87
89 Copyright (c) 2003-2007 David Rolsky. All rights reserved. This pro‐
90 gram is free software; you can redistribute it and/or modify it under
91 the same terms as Perl itself.
92
93 The full text of the license can be found in the LICENSE file included
94 with this module.
95
96
97
98perl v5.8.8 2007-04-02 DateTime::TimeZone::Local(3)