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::Local->TimeZone()
22 This attempts to load an appropriate subclass and asks it to find the
23 local time zone. This method is called by when you pass "local" as the
24 time zone name to "DateTime:TimeZone->new()".
25
26 If your OS is not explicitly handled, you can create a module with a
27 name of the form "DateTime::TimeZone::Local::$^O". If it exists, it
28 will be used instead of falling back to the Unix subclass.
29
30 If no OS-specific module exists, we fall back to using the Unix
31 subclass.
32
33 See DateTime::TimeZone::Local::Unix, DateTime::TimeZone::Local::Win32,
34 and DateTime::TimeZone::Local::VMS for OS-specific details.
35
37 If you want to make a new OS-specific subclass, there are several
38 methods provided by this module you should know about.
39
40 $class->Methods()
41 This method should be provided by your class. It should provide a list
42 of methods that will be called to try to determine the local time zone.
43
44 Each of these methods is expected to return a new "DateTime::TimeZone"
45 object if it determines the time zone.
46
47 $class->FromEnv()
48 This method tries to find a valid time zone in an %ENV value. It calls
49 "$class->EnvVars()" to determine which keys to look at.
50
51 To use this from a subclass, simply return "FromEnv" as one of the
52 items from "$class->Methods()".
53
54 $class->EnvVars()
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 Given a possible time zone name, this returns a boolean indicating
60 whether or not the the name looks valid. It always return false for
61 "local" in order to avoid infinite loops.
62
64 Here is a simple example subclass:
65
66 package DateTime::TimeZone::SomeOS;
67
68 use strict;
69 use warnings;
70
71 use base 'DateTime::TimeZone::Local';
72
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-2008 David Rolsky. All rights reserved. This
90 program is free software; you can redistribute it and/or modify it
91 under 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.10.1 2017-03-21 DateTime::TimeZone::Local(3)