-
-
17 Mar 2022 04:59:29 UTC
- Distribution: DateTime-TimeZone
- Module version: 2.52
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues
- Testers (1704 / 0 / 1)
- Kwalitee
Bus factor: 1- 41.89% Coverage
- License: perl_5
- Perl: v5.8.4
- Activity
24 month- Tools
- Download (990.97KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 18 contributors-
Alexey Molchanov
-
Alfie John
-
Andrew Paprocki
-
Bron Gondwana
-
Daisuke Maki
-
David Pinkowitz
- Iain Truskett <deceased>
-
Jakub Wilk
-
James E Keenan
-
Joshua Hoblitt
-
Karen Etheridge
-
karupanerura
-
kclaggett
-
Matthew Horsfall
-
Mohammad S Anwar
-
Olaf Alders
-
Peter Rabbitson
-
Tom Wyant
- Dependencies
- Class::Singleton
- Cwd
- File::Basename
- File::Compare
- File::Find
- File::Spec
- List::Util
- Module::Runtime
- Params::ValidationCompiler
- Specio::Library::Builtins
- Specio::Library::String
- Try::Tiny
- constant
- namespace::autoclean
- parent
- strict
- warnings
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- NAME
- VERSION
- SYNOPSIS
- DESCRIPTION
- HOW THE TIME ZONE IS DETERMINED
- SUPPORT
- SOURCE
- AUTHOR
- COPYRIGHT AND LICENSE
NAME
DateTime::TimeZone::Local::Unix - Determine the local system's time zone on Unix
VERSION
version 2.52
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 Unix platform.
HOW THE TIME ZONE IS DETERMINED
This class tries the following methods of determining the local time zone:
$ENV{TZ}
It checks
$ENV{TZ}
for a valid time zone name./etc/localtime
If this file is a symlink to an Olson database time zone file (usually in /usr/share/zoneinfo) then it uses the target file's path name to determine the time zone name. For example, if the path is /usr/share/zoneinfo/America/Chicago, the time zone is "America/Chicago".
Some systems just copy the relevant file to /etc/localtime instead of making a symlink. In this case, we look in /usr/share/zoneinfo for a file that has the same size and content as /etc/localtime to determine the local time zone.
/etc/timezone
If this file exists, it is read and its contents are used as a time zone name.
/etc/TIMEZONE
If this file exists, it is opened and we look for a line starting like "TZ = ...". If this is found, it should indicate a time zone name.
/etc/sysconfig/clock
If this file exists, it is opened and we look for a line starting like "TIMEZONE = ..." or "ZONE = ...". If this is found, it should indicate a time zone name.
/etc/default/init
If this file exists, it is opened and we look for a line starting like "TZ=...". If this is found, it should indicate a time zone name.
Note: Some systems such as virtual machine boxes may lack any of these files. You can confirm that this is case by running:
$ ls -l /etc/localtime /etc/timezone /etc/TIMEZONE \ /etc/sysconfig/clock /etc/default/init
If this is the case, then when checking for timezone handling you are likely to get an exception:
$ perl -wle 'use DateTime; DateTime->now( time_zone => "local" )' Cannot determine local time zone
In that case, you should consult your system man 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 tzsetup utility. That installed /etc/localtime, after which the above timezone diagnostic ran silently, i.e., without throwing an exception.
SUPPORT
Bugs may be submitted at https://github.com/houseabsolute/DateTime-TimeZone/issues.
SOURCE
The source code repository for DateTime-TimeZone can be found at https://github.com/houseabsolute/DateTime-TimeZone.
AUTHOR
Dave Rolsky <autarch@urth.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2022 by Dave Rolsky.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
The full text of the license can be found in the LICENSE file included with this distribution.
Module Install Instructions
To install DateTime::TimeZone, copy and paste the appropriate command in to your terminal.
cpanm DateTime::TimeZone
perl -MCPAN -e shell install DateTime::TimeZone
For more information on module installation, please visit the detailed CPAN module installation guide.