.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DateTime::TimeZone::Local::Unix 3pm" .TH DateTime::TimeZone::Local::Unix 3pm "2023-03-29" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DateTime::TimeZone::Local::Unix \- Determine the local system's time zone on Unix .SH "VERSION" .IX Header "VERSION" version 2.47 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& my $tz = DateTime::TimeZone\->new( name => \*(Aqlocal\*(Aq ); \& \& my $tz = DateTime::TimeZone::Local\->TimeZone(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides methods for determining the local time zone on a Unix platform. .SH "HOW THE TIME ZONE IS DETERMINED" .IX Header "HOW THE TIME ZONE IS DETERMINED" This class tries the following methods of determining the local time zone: .IP "\(bu" 4 \&\f(CW$ENV\fR{\s-1TZ\s0} .Sp It checks \f(CW$ENV{TZ}\fR for a valid time zone name. .IP "\(bu" 4 \&\fI/etc/localtime\fR .Sp If this file is a symlink to an Olson database time zone file (usually in \fI/usr/share/zoneinfo\fR) then it uses the target file's path name to determine the time zone name. For example, if the path is \&\fI/usr/share/zoneinfo/America/Chicago\fR, the time zone is \&\*(L"America/Chicago\*(R". .Sp Some systems just copy the relevant file to \fI/etc/localtime\fR instead of making a symlink. In this case, we look in \fI/usr/share/zoneinfo\fR for a file that has the same size and content as \fI/etc/localtime\fR to determine the local time zone. .IP "\(bu" 4 \&\fI/etc/timezone\fR .Sp If this file exists, it is read and its contents are used as a time zone name. .IP "\(bu" 4 \&\fI/etc/TIMEZONE\fR .Sp If this file exists, it is opened and we look for a line starting like \&\*(L"\s-1TZ\s0 = ...\*(R". If this is found, it should indicate a time zone name. .IP "\(bu" 4 \&\fI/etc/sysconfig/clock\fR .Sp If this file exists, it is opened and we look for a line starting like \&\*(L"\s-1TIMEZONE\s0 = ...\*(R" or \*(L"\s-1ZONE\s0 = ...\*(R". If this is found, it should indicate a time zone name. .IP "\(bu" 4 \&\fI/etc/default/init\fR .Sp If this file exists, it is opened and we look for a line starting like \&\*(L"TZ=...\*(R". If this is found, it should indicate a time zone name. .PP \&\fBNote:\fR Some systems such as virtual machine boxes may lack any of these files. You can confirm that this is case by running: .PP .Vb 2 \& $ ls \-l /etc/localtime /etc/timezone /etc/TIMEZONE \e \& /etc/sysconfig/clock /etc/default/init .Ve .PP If this is the case, then when checking for timezone handling you are likely to get an exception: .PP .Vb 2 \& $ perl \-wle \*(Aquse DateTime; DateTime\->now( time_zone => "local" )\*(Aq \& Cannot determine local time zone .Ve .PP In that case, you should consult your system \fIman\fR pages for details on how to address that problem. In one such case reported to us, a FreeBSD virtual machine had been built without any of these files. The user was able to run the FreeBSD \fItzsetup\fR utility. That installed \fI/etc/localtime\fR, after which the above timezone diagnostic ran silently, \fIi.e.\fR, without throwing an exception. .SH "SUPPORT" .IX Header "SUPPORT" Bugs may be submitted at . .PP I am also usually active on \s-1IRC\s0 as 'autarch' on \f(CW\*(C`irc://irc.perl.org\*(C'\fR. .SH "SOURCE" .IX Header "SOURCE" The source code repository for DateTime-TimeZone can be found at . .SH "AUTHOR" .IX Header "AUTHOR" Dave Rolsky .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2021 by Dave Rolsky. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. .PP The full text of the license can be found in the \&\fI\s-1LICENSE\s0\fR file included with this distribution.