Initial Commit
This commit is contained in:
46
database/perl/vendor/lib/DateTime/TimeZone/Local/Android.pm
vendored
Normal file
46
database/perl/vendor/lib/DateTime/TimeZone/Local/Android.pm
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
package DateTime::TimeZone::Local::Android;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use namespace::autoclean;
|
||||
|
||||
our $VERSION = '2.46';
|
||||
|
||||
use Try::Tiny;
|
||||
|
||||
use parent 'DateTime::TimeZone::Local';
|
||||
|
||||
sub Methods {
|
||||
return qw(
|
||||
FromEnv
|
||||
FromGetProp
|
||||
FromDefault
|
||||
);
|
||||
}
|
||||
|
||||
sub EnvVars { return 'TZ' }
|
||||
|
||||
# https://chromium.googlesource.com/native_client/nacl-bionic/+/upstream/master/libc/tzcode/localtime.c
|
||||
sub FromGetProp {
|
||||
## no critic (InputOutput::ProhibitBacktickOperators)
|
||||
my $name = `getprop persist.sys.timezone`;
|
||||
chomp $name;
|
||||
my $tz = try {
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $SIG{__DIE__};
|
||||
DateTime::TimeZone->new( name => $name );
|
||||
};
|
||||
|
||||
return $tz if $tz;
|
||||
}
|
||||
|
||||
# See the link above. Android always defaults to UTC
|
||||
sub FromDefault {
|
||||
return try {
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $SIG{__DIE__};
|
||||
DateTime::TimeZone->new( name => 'UTC' );
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
389
database/perl/vendor/lib/DateTime/TimeZone/Local/Unix.pm
vendored
Normal file
389
database/perl/vendor/lib/DateTime/TimeZone/Local/Unix.pm
vendored
Normal file
@@ -0,0 +1,389 @@
|
||||
package DateTime::TimeZone::Local::Unix;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use namespace::autoclean;
|
||||
|
||||
our $VERSION = '2.46';
|
||||
|
||||
use Cwd 3;
|
||||
use Try::Tiny;
|
||||
|
||||
use parent 'DateTime::TimeZone::Local';
|
||||
|
||||
sub Methods {
|
||||
return qw(
|
||||
FromEnv
|
||||
FromEtcTimezone
|
||||
FromEtcLocaltime
|
||||
FromEtcTIMEZONE
|
||||
FromEtcSysconfigClock
|
||||
FromEtcDefaultInit
|
||||
);
|
||||
}
|
||||
|
||||
sub EnvVars { return 'TZ' }
|
||||
|
||||
## no critic (Variables::ProhibitPackageVars)
|
||||
our $EtcDir = '/etc';
|
||||
## use critic
|
||||
|
||||
sub _EtcFile {
|
||||
shift;
|
||||
return File::Spec->catfile( $EtcDir, @_ );
|
||||
}
|
||||
|
||||
sub FromEtcLocaltime {
|
||||
my $class = shift;
|
||||
|
||||
my $lt_file = $class->_EtcFile('localtime');
|
||||
return unless -r $lt_file && -s _;
|
||||
|
||||
my $real_name;
|
||||
if ( -l $lt_file ) {
|
||||
|
||||
# The _Readlink sub exists so the test suite can mock it.
|
||||
$real_name = $class->_Readlink($lt_file);
|
||||
}
|
||||
|
||||
$real_name ||= $class->_FindMatchingZoneinfoFile($lt_file);
|
||||
|
||||
if ( defined $real_name ) {
|
||||
my ( undef, $dirs, $file ) = File::Spec->splitpath($real_name);
|
||||
|
||||
my @parts = grep { defined && length } File::Spec->splitdir($dirs),
|
||||
$file;
|
||||
|
||||
foreach my $x ( reverse 0 .. $#parts ) {
|
||||
my $name = (
|
||||
$x < $#parts
|
||||
? join '/', @parts[ $x .. $#parts ]
|
||||
: $parts[$x]
|
||||
);
|
||||
|
||||
my $tz = try {
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $SIG{__DIE__};
|
||||
DateTime::TimeZone->new( name => $name );
|
||||
};
|
||||
|
||||
return $tz if $tz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub _Readlink {
|
||||
my $link = $_[1];
|
||||
|
||||
# Using abs_path will resolve multiple levels of link indirection,
|
||||
# whereas readlink just follows the link to the next target.
|
||||
return Cwd::abs_path($link);
|
||||
}
|
||||
|
||||
## no critic (Variables::ProhibitPackageVars)
|
||||
our $ZoneinfoDir = '/usr/share/zoneinfo';
|
||||
## use critic
|
||||
|
||||
# for systems where /etc/localtime is a copy of a zoneinfo file
|
||||
sub _FindMatchingZoneinfoFile {
|
||||
shift;
|
||||
my $file_to_match = shift;
|
||||
|
||||
# For some reason, under at least macOS 10.13 High Sierra,
|
||||
# /usr/share/zoneinfo is a link to a link to a directory. And no, I didn't
|
||||
# stutter. This is fine, and it passes the -d below. But File::Find does
|
||||
# not understand a link to be a directory, so rather than incur the
|
||||
# overhead of telling File::Find::find() to follow symbolic links, we just
|
||||
# resolve it here.
|
||||
my $zone_info_dir = $ZoneinfoDir;
|
||||
$zone_info_dir = readlink $zone_info_dir while -l $zone_info_dir;
|
||||
|
||||
return unless -d $zone_info_dir;
|
||||
|
||||
require File::Basename;
|
||||
require File::Compare;
|
||||
require File::Find;
|
||||
|
||||
my $size = -s $file_to_match;
|
||||
|
||||
my $real_name;
|
||||
try {
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $SIG{__DIE__};
|
||||
local $_;
|
||||
|
||||
File::Find::find(
|
||||
{
|
||||
wanted => sub {
|
||||
if (
|
||||
!defined $real_name
|
||||
&& -f $_
|
||||
&& !-l $_
|
||||
&& $size == -s _
|
||||
|
||||
# This fixes RT 24026 - apparently such a
|
||||
# file exists on FreeBSD and it can cause a
|
||||
# false positive
|
||||
&& File::Basename::basename($_) ne 'posixrules'
|
||||
&& File::Compare::compare( $_, $file_to_match ) == 0
|
||||
) {
|
||||
$real_name = $_;
|
||||
|
||||
# File::Find has no mechanism for bailing in the
|
||||
# middle of a find.
|
||||
die { found => 1 };
|
||||
}
|
||||
},
|
||||
no_chdir => 1,
|
||||
},
|
||||
$zone_info_dir,
|
||||
);
|
||||
}
|
||||
catch {
|
||||
die $_ unless ref $_ && $_->{found};
|
||||
};
|
||||
|
||||
return $real_name;
|
||||
}
|
||||
|
||||
sub FromEtcTimezone {
|
||||
my $class = shift;
|
||||
|
||||
my $tz_file = $class->_EtcFile('timezone');
|
||||
return unless -f $tz_file && -r _;
|
||||
|
||||
open my $fh, '<', $tz_file
|
||||
or die "Cannot read $tz_file: $!";
|
||||
my $name = do { local $/ = undef; <$fh> };
|
||||
close $fh or die $!;
|
||||
|
||||
$name =~ s/^\s+|\s+$//g;
|
||||
|
||||
return unless $class->_IsValidName($name);
|
||||
|
||||
return try {
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $SIG{__DIE__};
|
||||
DateTime::TimeZone->new( name => $name );
|
||||
};
|
||||
}
|
||||
|
||||
sub FromEtcTIMEZONE {
|
||||
my $class = shift;
|
||||
|
||||
my $tz_file = $class->_EtcFile('TIMEZONE');
|
||||
return unless -f $tz_file && -r _;
|
||||
|
||||
## no critic (InputOutput::RequireBriefOpen)
|
||||
open my $fh, '<', $tz_file
|
||||
or die "Cannot read $tz_file: $!";
|
||||
|
||||
my $name;
|
||||
while ( defined( $name = <$fh> ) ) {
|
||||
if ( $name =~ /\A\s*TZ\s*=\s*(\S+)/ ) {
|
||||
$name = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
close $fh or die $!;
|
||||
|
||||
return unless $class->_IsValidName($name);
|
||||
|
||||
return try {
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $SIG{__DIE__};
|
||||
DateTime::TimeZone->new( name => $name );
|
||||
};
|
||||
}
|
||||
|
||||
# RedHat uses this
|
||||
sub FromEtcSysconfigClock {
|
||||
my $class = shift;
|
||||
|
||||
my $clock_file = $class->_EtcFile('sysconfig/clock');
|
||||
return unless -r $clock_file && -f _;
|
||||
|
||||
my $name = $class->_ReadEtcSysconfigClock($clock_file);
|
||||
|
||||
return unless $class->_IsValidName($name);
|
||||
|
||||
return try {
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $SIG{__DIE__};
|
||||
DateTime::TimeZone->new( name => $name );
|
||||
};
|
||||
}
|
||||
|
||||
# this is a separate function so that it can be overridden in the test suite
|
||||
sub _ReadEtcSysconfigClock {
|
||||
shift;
|
||||
my $clock_file = shift;
|
||||
|
||||
open my $fh, '<', $clock_file
|
||||
or die "Cannot read $clock_file: $!";
|
||||
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $_;
|
||||
while (<$fh>) {
|
||||
return $1 if /^(?:TIME)?ZONE="([^"]+)"/;
|
||||
}
|
||||
|
||||
close $fh or die $!;
|
||||
}
|
||||
|
||||
sub FromEtcDefaultInit {
|
||||
my $class = shift;
|
||||
|
||||
my $init_file = $class->_EtcFile('default/init');
|
||||
return unless -r $init_file && -f _;
|
||||
|
||||
my $name = $class->_ReadEtcDefaultInit($init_file);
|
||||
|
||||
return unless $class->_IsValidName($name);
|
||||
|
||||
return try {
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $SIG{__DIE__};
|
||||
DateTime::TimeZone->new( name => $name );
|
||||
};
|
||||
}
|
||||
|
||||
# this is a separate function so that it can be overridden in the test
|
||||
# suite
|
||||
sub _ReadEtcDefaultInit {
|
||||
shift;
|
||||
my $init_file = shift;
|
||||
|
||||
open my $fh, '<', $init_file
|
||||
or die "Cannot read $init_file: $!";
|
||||
|
||||
## no critic (Variables::RequireInitializationForLocalVars)
|
||||
local $_;
|
||||
while (<$fh>) {
|
||||
return $1 if /^TZ=(.+)/;
|
||||
}
|
||||
|
||||
close $fh or die $!;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Determine the local system's time zone on Unix
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
DateTime::TimeZone::Local::Unix - Determine the local system's time zone on Unix
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.46
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $tz = DateTime::TimeZone->new( name => 'local' );
|
||||
|
||||
my $tz = DateTime::TimeZone::Local->TimeZone();
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module provides methods for determining the local time zone on a
|
||||
Unix platform.
|
||||
|
||||
=head1 HOW THE TIME ZONE IS DETERMINED
|
||||
|
||||
This class tries the following methods of determining the local time
|
||||
zone:
|
||||
|
||||
=over 4
|
||||
|
||||
=item * $ENV{TZ}
|
||||
|
||||
It checks C<< $ENV{TZ} >> for a valid time zone name.
|
||||
|
||||
=item * F</etc/localtime>
|
||||
|
||||
If this file is a symlink to an Olson database time zone file (usually
|
||||
in F</usr/share/zoneinfo>) then it uses the target file's path name to
|
||||
determine the time zone name. For example, if the path is
|
||||
F</usr/share/zoneinfo/America/Chicago>, the time zone is
|
||||
"America/Chicago".
|
||||
|
||||
Some systems just copy the relevant file to F</etc/localtime> instead
|
||||
of making a symlink. In this case, we look in F</usr/share/zoneinfo>
|
||||
for a file that has the same size and content as F</etc/localtime> to
|
||||
determine the local time zone.
|
||||
|
||||
=item * F</etc/timezone>
|
||||
|
||||
If this file exists, it is read and its contents are used as a time
|
||||
zone name.
|
||||
|
||||
=item * F</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.
|
||||
|
||||
=item * F</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.
|
||||
|
||||
=item * F</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.
|
||||
|
||||
=back
|
||||
|
||||
B<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 F<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 F<tzsetup> utility. That installed F</etc/localtime>, after which
|
||||
the above timezone diagnostic ran silently, I<i.e.>, without throwing an
|
||||
exception.
|
||||
|
||||
=head1 SUPPORT
|
||||
|
||||
Bugs may be submitted at L<https://github.com/houseabsolute/DateTime-TimeZone/issues>.
|
||||
|
||||
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
|
||||
|
||||
=head1 SOURCE
|
||||
|
||||
The source code repository for DateTime-TimeZone can be found at L<https://github.com/houseabsolute/DateTime-TimeZone>.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2020 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
|
||||
F<LICENSE> file included with this distribution.
|
||||
|
||||
=cut
|
||||
100
database/perl/vendor/lib/DateTime/TimeZone/Local/VMS.pm
vendored
Normal file
100
database/perl/vendor/lib/DateTime/TimeZone/Local/VMS.pm
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
package DateTime::TimeZone::Local::VMS;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use namespace::autoclean;
|
||||
|
||||
our $VERSION = '2.46';
|
||||
|
||||
use parent 'DateTime::TimeZone::Local';
|
||||
|
||||
sub Methods { return qw( FromEnv ) }
|
||||
|
||||
sub EnvVars {
|
||||
return qw( TZ SYS$TIMEZONE_RULE SYS$TIMEZONE_NAME UCX$TZ TCPIP$TZ );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Determine the local system's time zone on VMS
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
DateTime::TimeZone::Local::VMS - Determine the local system's time zone on VMS
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.46
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $tz = DateTime::TimeZone->new( name => 'local' );
|
||||
|
||||
my $tz = DateTime::TimeZone::Local->TimeZone();
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module provides methods for determining the local time zone on a
|
||||
VMS platform.
|
||||
|
||||
NOTE: This is basically a stub pending an implementation by someone
|
||||
who knows something about VMS.
|
||||
|
||||
=head1 HOW THE TIME ZONE IS DETERMINED
|
||||
|
||||
This class tries the following methods of determining the local time
|
||||
zone:
|
||||
|
||||
=over 4
|
||||
|
||||
=item * %ENV
|
||||
|
||||
We check the following environment variables:
|
||||
|
||||
=over 8
|
||||
|
||||
=item * TZ
|
||||
|
||||
=item * SYS$TIMEZONE_RULE
|
||||
|
||||
=item * SYS$TIMEZONE_NAME
|
||||
|
||||
=item * UCX$TZ
|
||||
|
||||
=item * TCPIP$TZ
|
||||
|
||||
=back
|
||||
|
||||
=back
|
||||
|
||||
=head1 SUPPORT
|
||||
|
||||
Bugs may be submitted at L<https://github.com/houseabsolute/DateTime-TimeZone/issues>.
|
||||
|
||||
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>.
|
||||
|
||||
=head1 SOURCE
|
||||
|
||||
The source code repository for DateTime-TimeZone can be found at L<https://github.com/houseabsolute/DateTime-TimeZone>.
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
This software is copyright (c) 2020 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
|
||||
F<LICENSE> file included with this distribution.
|
||||
|
||||
=cut
|
||||
407
database/perl/vendor/lib/DateTime/TimeZone/Local/Win32.pm
vendored
Normal file
407
database/perl/vendor/lib/DateTime/TimeZone/Local/Win32.pm
vendored
Normal file
@@ -0,0 +1,407 @@
|
||||
package DateTime::TimeZone::Local::Win32;
|
||||
$DateTime::TimeZone::Local::Win32::VERSION = '2.04';
|
||||
use 5.006;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Try::Tiny;
|
||||
use Win32::TieRegistry 0.27 ( 'KEY_READ', Delimiter => q{/} );
|
||||
|
||||
use parent 'DateTime::TimeZone::Local';
|
||||
|
||||
sub Methods { return qw( FromEnv FromRegistry ) }
|
||||
|
||||
sub EnvVars { return 'TZ' }
|
||||
|
||||
{
|
||||
# This list comes (mostly) in the zipball for the Chronos project
|
||||
# - a Smalltalk datetime library. Thanks, Chronos!
|
||||
my %WinToIANA = (
|
||||
'Afghanistan' => 'Asia/Kabul',
|
||||
'Afghanistan Standard Time' => 'Asia/Kabul',
|
||||
'Alaskan' => 'America/Anchorage',
|
||||
'Alaskan Standard Time' => 'America/Anchorage',
|
||||
'Aleutian Standard Time' => 'America/Adak',
|
||||
'Altai Standard Time' => 'Asia/Barnaul',
|
||||
'Arab' => 'Asia/Riyadh',
|
||||
'Arab Standard Time' => 'Asia/Riyadh',
|
||||
'Arabian' => 'Asia/Muscat',
|
||||
'Arabian Standard Time' => 'Asia/Muscat',
|
||||
'Arabic Standard Time' => 'Asia/Baghdad',
|
||||
'Argentina Standard Time' => 'America/Argentina/Buenos_Aires',
|
||||
'Armenian Standard Time' => 'Asia/Yerevan',
|
||||
'Astrakhan Standard Time' => 'Europe/Astrakhan',
|
||||
'Atlantic' => 'America/Halifax',
|
||||
'Atlantic Standard Time' => 'America/Halifax',
|
||||
'AUS Central' => 'Australia/Darwin',
|
||||
'AUS Central Standard Time' => 'Australia/Darwin',
|
||||
'Aus Central W. Standard Time' => 'Australia/Eucla',
|
||||
'AUS Eastern' => 'Australia/Sydney',
|
||||
'AUS Eastern Standard Time' => 'Australia/Sydney',
|
||||
'Azerbaijan Standard Time' => 'Asia/Baku',
|
||||
'Azores' => 'Atlantic/Azores',
|
||||
'Azores Standard Time' => 'Atlantic/Azores',
|
||||
'Bahia Standard Time' => 'America/Bahia',
|
||||
'Bangkok' => 'Asia/Bangkok',
|
||||
'Bangkok Standard Time' => 'Asia/Bangkok',
|
||||
'Bangladesh Standard Time' => 'Asia/Dhaka',
|
||||
'Beijing' => 'Asia/Shanghai',
|
||||
'Belarus Standard Time' => 'Europe/Minsk',
|
||||
'Bougainville Standard Time' => 'Pacific/Bougainville',
|
||||
'Canada Central' => 'America/Regina',
|
||||
'Canada Central Standard Time' => 'America/Regina',
|
||||
'Cape Verde Standard Time' => 'Atlantic/Cape_Verde',
|
||||
'Caucasus' => 'Asia/Yerevan',
|
||||
'Caucasus Standard Time' => 'Asia/Yerevan',
|
||||
'Cen. Australia' => 'Australia/Adelaide',
|
||||
'Cen. Australia Standard Time' => 'Australia/Adelaide',
|
||||
'Central' => 'America/Chicago',
|
||||
'Central America Standard Time' => 'America/Tegucigalpa',
|
||||
'Central Asia' => 'Asia/Almaty',
|
||||
'Central Asia Standard Time' => 'Asia/Almaty',
|
||||
'Central Brazilian Standard Time' => 'America/Cuiaba',
|
||||
'Central Europe' => 'Europe/Prague',
|
||||
'Central Europe Standard Time' => 'Europe/Prague',
|
||||
'Central European' => 'Europe/Belgrade',
|
||||
'Central European Standard Time' => 'Europe/Warsaw',
|
||||
'Central Pacific' => 'Pacific/Guadalcanal',
|
||||
'Central Pacific Standard Time' => 'Pacific/Guadalcanal',
|
||||
'Central Standard Time' => 'America/Chicago',
|
||||
'Central Standard Time (Mexico)' => 'America/Mexico_City',
|
||||
'Chatham Islands Standard Time' => 'Pacific/Chatham',
|
||||
'China' => 'Asia/Shanghai',
|
||||
'China Standard Time' => 'Asia/Shanghai',
|
||||
'Cuba Standard Time' => 'America/Havana',
|
||||
'Dateline' => '-1200',
|
||||
'Dateline Standard Time' => '-1200',
|
||||
'E. Africa' => 'Africa/Nairobi',
|
||||
'E. Africa Standard Time' => 'Africa/Nairobi',
|
||||
'E. Australia' => 'Australia/Brisbane',
|
||||
'E. Australia Standard Time' => 'Australia/Brisbane',
|
||||
'E. Europe' => 'Europe/Helsinki',
|
||||
'E. Europe Standard Time' => 'Europe/Chisinau',
|
||||
'E. South America' => 'America/Sao_Paulo',
|
||||
'E. South America Standard Time' => 'America/Sao_Paulo',
|
||||
'Easter Island Standard Time' => 'Pacific/Easter',
|
||||
'Eastern' => 'America/New_York',
|
||||
'Eastern Standard Time' => 'America/New_York',
|
||||
'Eastern Standard Time (Mexico)' => 'America/Cancun',
|
||||
'Egypt' => 'Africa/Cairo',
|
||||
'Egypt Standard Time' => 'Africa/Cairo',
|
||||
'Ekaterinburg' => 'Asia/Yekaterinburg',
|
||||
'Ekaterinburg Standard Time' => 'Asia/Yekaterinburg',
|
||||
'Fiji' => 'Pacific/Fiji',
|
||||
'Fiji Standard Time' => 'Pacific/Fiji',
|
||||
'FLE' => 'Europe/Helsinki',
|
||||
'FLE Standard Time' => 'Europe/Helsinki',
|
||||
'Georgian Standard Time' => 'Asia/Tbilisi',
|
||||
'GFT' => 'Europe/Athens',
|
||||
'GFT Standard Time' => 'Europe/Athens',
|
||||
'GMT' => 'Europe/London',
|
||||
'GMT Standard Time' => 'Europe/London',
|
||||
'Greenland Standard Time' => 'America/Godthab',
|
||||
'Greenwich' => 'GMT',
|
||||
'Greenwich Standard Time' => 'GMT',
|
||||
'GTB' => 'Europe/Athens',
|
||||
'GTB Standard Time' => 'Europe/Athens',
|
||||
'Haiti Standard Time' => 'America/Port-au-Prince',
|
||||
'Hawaiian' => 'Pacific/Honolulu',
|
||||
'Hawaiian Standard Time' => 'Pacific/Honolulu',
|
||||
'India' => 'Asia/Calcutta',
|
||||
'India Standard Time' => 'Asia/Kolkata',
|
||||
'Iran' => 'Asia/Tehran',
|
||||
'Iran Standard Time' => 'Asia/Tehran',
|
||||
'Israel' => 'Asia/Jerusalem',
|
||||
'Israel Standard Time' => 'Asia/Jerusalem',
|
||||
'Jordan Standard Time' => 'Asia/Amman',
|
||||
'Kaliningrad Standard Time' => 'Europe/Kaliningrad',
|
||||
'Kamchatka Standard Time' => 'Asia/Kamchatka',
|
||||
'Korea' => 'Asia/Seoul',
|
||||
'Korea Standard Time' => 'Asia/Seoul',
|
||||
'Libya Standard Time' => 'Africa/Tripoli',
|
||||
'Line Islands Standard Time' => 'Pacific/Kiritimati',
|
||||
'Lord Howe Standard Time' => 'Australia/Lord_Howe',
|
||||
'Magadan Standard Time' => 'Asia/Magadan',
|
||||
'Magallanes Standard Time' => 'America/Punta_Arenas',
|
||||
'Marquesas Standard Time' => 'Pacific/Marquesas',
|
||||
'Mauritius Standard Time' => 'Indian/Mauritius',
|
||||
'Mexico' => 'America/Mexico_City',
|
||||
'Mexico Standard Time' => 'America/Mexico_City',
|
||||
'Mexico Standard Time 2' => 'America/Chihuahua',
|
||||
'Mid-Atlantic' => 'Atlantic/South_Georgia',
|
||||
'Mid-Atlantic Standard Time' => 'Atlantic/South_Georgia',
|
||||
'Middle East Standard Time' => 'Asia/Beirut',
|
||||
'Montevideo Standard Time' => 'America/Montevideo',
|
||||
'Morocco Standard Time' => 'Africa/Casablanca',
|
||||
'Mountain' => 'America/Denver',
|
||||
'Mountain Standard Time' => 'America/Denver',
|
||||
'Mountain Standard Time (Mexico)' => 'America/Chihuahua',
|
||||
'Myanmar Standard Time' => 'Asia/Rangoon',
|
||||
'N. Central Asia Standard Time' => 'Asia/Novosibirsk',
|
||||
'Namibia Standard Time' => 'Africa/Windhoek',
|
||||
'Nepal Standard Time' => 'Asia/Katmandu',
|
||||
'New Zealand' => 'Pacific/Auckland',
|
||||
'New Zealand Standard Time' => 'Pacific/Auckland',
|
||||
'Newfoundland' => 'America/St_Johns',
|
||||
'Newfoundland Standard Time' => 'America/St_Johns',
|
||||
'Norfolk Standard Time' => 'Pacific/Norfolk',
|
||||
'North Asia East Standard Time' => 'Asia/Irkutsk',
|
||||
'North Asia Standard Time' => 'Asia/Krasnoyarsk',
|
||||
'North Korea Standard Time' => 'Asia/Pyongyang',
|
||||
'Omsk Standard Time' => 'Asia/Omsk',
|
||||
'Pacific' => 'America/Los_Angeles',
|
||||
'Pacific SA' => 'America/Santiago',
|
||||
'Pacific SA Standard Time' => 'America/Santiago',
|
||||
'Pacific Standard Time' => 'America/Los_Angeles',
|
||||
'Pacific Standard Time (Mexico)' => 'America/Tijuana',
|
||||
'Pakistan Standard Time' => 'Asia/Karachi',
|
||||
'Paraguay Standard Time' => 'America/Asuncion',
|
||||
'Prague Bratislava' => 'Europe/Prague',
|
||||
'Qyzylorda Standard Time' => 'Asia/Qyzylorda',
|
||||
'Romance' => 'Europe/Paris',
|
||||
'Romance Standard Time' => 'Europe/Paris',
|
||||
'Russia Time Zone 10' => 'Asia/Srednekolymsk',
|
||||
'Russia Time Zone 11' => 'Asia/Anadyr',
|
||||
'Russia Time Zone 3' => 'Europe/Samara',
|
||||
'Russian' => 'Europe/Moscow',
|
||||
'Russian Standard Time' => 'Europe/Moscow',
|
||||
'SA Eastern' => 'America/Cayenne',
|
||||
'SA Eastern Standard Time' => 'America/Cayenne',
|
||||
'SA Pacific' => 'America/Bogota',
|
||||
'SA Pacific Standard Time' => 'America/Bogota',
|
||||
'SA Western' => 'America/Guyana',
|
||||
'SA Western Standard Time' => 'America/Guyana',
|
||||
'Saint Pierre Standard Time' => 'America/Miquelon',
|
||||
'Sakhalin Standard Time' => 'Asia/Sakhalin',
|
||||
'Samoa' => 'Pacific/Apia',
|
||||
'Samoa Standard Time' => 'Pacific/Apia',
|
||||
'Sao Tome Standard Time' => 'Africa/Sao_Tome',
|
||||
'Saratov Standard Time' => 'Europe/Saratov',
|
||||
'Saudi Arabia' => 'Asia/Riyadh',
|
||||
'Saudi Arabia Standard Time' => 'Asia/Riyadh',
|
||||
'SE Asia' => 'Asia/Bangkok',
|
||||
'SE Asia Standard Time' => 'Asia/Bangkok',
|
||||
'Singapore' => 'Asia/Singapore',
|
||||
'Singapore Standard Time' => 'Asia/Singapore',
|
||||
'South Africa' => 'Africa/Harare',
|
||||
'South Africa Standard Time' => 'Africa/Harare',
|
||||
'Sri Lanka' => 'Asia/Colombo',
|
||||
'Sri Lanka Standard Time' => 'Asia/Colombo',
|
||||
'Sudan Standard Time' => 'Africa/Khartoum',
|
||||
'Syria Standard Time' => 'Asia/Damascus',
|
||||
'Sydney Standard Time' => 'Australia/Sydney',
|
||||
'Taipei' => 'Asia/Taipei',
|
||||
'Taipei Standard Time' => 'Asia/Taipei',
|
||||
'Tasmania' => 'Australia/Hobart',
|
||||
'Tasmania Standard Time' => 'Australia/Hobart',
|
||||
'Tocantins Standard Time' => 'America/Araguaina',
|
||||
'Tokyo' => 'Asia/Tokyo',
|
||||
'Tokyo Standard Time' => 'Asia/Tokyo',
|
||||
'Tomsk Standard Time' => 'Asia/Tomsk',
|
||||
'Tonga Standard Time' => 'Pacific/Tongatapu',
|
||||
'Transbaikal Standard Time' => 'Asia/Chita',
|
||||
'Turkey Standard Time' => 'Europe/Istanbul',
|
||||
'Turks And Caicos Standard Time' => 'America/Grand_Turk',
|
||||
'Ulaanbaatar Standard Time' => 'Asia/Ulaanbaatar',
|
||||
'US Eastern' => 'America/Indianapolis',
|
||||
'US Eastern Standard Time' => 'America/Indianapolis',
|
||||
'US Mountain' => 'America/Phoenix',
|
||||
'US Mountain Standard Time' => 'America/Phoenix',
|
||||
'UTC' => 'UTC',
|
||||
'UTC+13' => '+1300',
|
||||
'UTC+12' => '+1200',
|
||||
'UTC-02' => '-0200',
|
||||
'UTC-08' => '-0800',
|
||||
'UTC-09' => '-0900',
|
||||
'UTC-11' => '-1100',
|
||||
'Venezuela Standard Time' => 'America/Caracas',
|
||||
'Vladivostok' => 'Asia/Vladivostok',
|
||||
'Vladivostok Standard Time' => 'Asia/Vladivostok',
|
||||
'Volgograd Standard Time' => 'Europe/Volgograd',
|
||||
'W. Australia' => 'Australia/Perth',
|
||||
'W. Australia Standard Time' => 'Australia/Perth',
|
||||
'W. Central Africa Standard Time' => 'Africa/Luanda',
|
||||
'W. Europe' => 'Europe/Berlin',
|
||||
'W. Europe Standard Time' => 'Europe/Berlin',
|
||||
'W. Mongolia Standard Time' => 'Asia/Hovd',
|
||||
'Warsaw' => 'Europe/Warsaw',
|
||||
'West Asia' => 'Asia/Karachi',
|
||||
'West Asia Standard Time' => 'Asia/Tashkent',
|
||||
'West Bank Standard Time' => 'Asia/Gaza',
|
||||
'West Pacific' => 'Pacific/Guam',
|
||||
'West Pacific Standard Time' => 'Pacific/Guam',
|
||||
'Western Brazilian Standard Time' => 'America/Rio_Branco',
|
||||
'Yakutsk' => 'Asia/Yakutsk',
|
||||
'Yakutsk Standard Time' => 'Asia/Yakutsk',
|
||||
);
|
||||
|
||||
sub _WindowsToIANA {
|
||||
my $class = shift;
|
||||
|
||||
my $win_name = shift;
|
||||
|
||||
# On Windows 2008 Server, there is additional junk after a
|
||||
# null character.
|
||||
$win_name =~ s/\0.*$//s
|
||||
if defined $win_name;
|
||||
|
||||
return unless defined $win_name;
|
||||
|
||||
return $WinToIANA{$win_name};
|
||||
}
|
||||
|
||||
sub FromRegistry {
|
||||
my $class = shift;
|
||||
|
||||
my $win_name = $class->_FindWindowsTZName();
|
||||
|
||||
my $iana = $class->_WindowsToIANA($win_name);
|
||||
|
||||
return unless $iana;
|
||||
|
||||
return unless $class->_IsValidName($iana);
|
||||
|
||||
return try {
|
||||
local $SIG{__DIE__};
|
||||
DateTime::TimeZone->new( name => $iana );
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
sub _FindWindowsTZName {
|
||||
my $class = shift;
|
||||
|
||||
my $LMachine = $Registry->Open( 'LMachine/', { Access => KEY_READ } );
|
||||
|
||||
my $TimeZoneInfo = $LMachine->{
|
||||
'SYSTEM/CurrentControlSet/Control/TimeZoneInformation/'};
|
||||
|
||||
# Windows Vista, Windows 2008 Server
|
||||
if ( defined $TimeZoneInfo->{'/TimeZoneKeyName'}
|
||||
&& $TimeZoneInfo->{'/TimeZoneKeyName'} ne '' ) {
|
||||
return $TimeZoneInfo->{'/TimeZoneKeyName'};
|
||||
}
|
||||
else {
|
||||
my $AllTimeZones = $LMachine->{
|
||||
'SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time Zones/'}
|
||||
|
||||
# Windows NT, Windows 2000, Windows XP, Windows 2003 Server
|
||||
? $LMachine->{
|
||||
'SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time Zones/'}
|
||||
|
||||
# Windows 95, Windows 98, Windows Millenium Edition
|
||||
: $LMachine->{
|
||||
'SOFTWARE/Microsoft/Windows/CurrentVersion/Time Zones/'};
|
||||
|
||||
foreach my $zone ( $AllTimeZones->SubKeyNames() ) {
|
||||
if ( $AllTimeZones->{ $zone . '/Std' } eq
|
||||
$TimeZoneInfo->{'/StandardName'} ) {
|
||||
return $zone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
# ABSTRACT: Determine the local system's time zone on Windows
|
||||
|
||||
__END__
|
||||
|
||||
=pod
|
||||
|
||||
=encoding UTF-8
|
||||
|
||||
=head1 NAME
|
||||
|
||||
DateTime::TimeZone::Local::Win32 - Determine the local system's time zone on Windows
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
version 2.04
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
my $tz = DateTime::TimeZone->new( name => 'local' );
|
||||
|
||||
my $tz = DateTime::TimeZone::Local->TimeZone();
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This module provides methods for determining the local time zone on a
|
||||
Windows platform.
|
||||
|
||||
=head1 NAME
|
||||
|
||||
DateTime::TimeZone::Local::Win32 - Determine the local system's time zone on Windows
|
||||
|
||||
=head1 HOW THE TIME ZONE IS DETERMINED
|
||||
|
||||
This class tries the following methods of determining the local time
|
||||
zone:
|
||||
|
||||
=over 4
|
||||
|
||||
=item * $ENV{TZ}
|
||||
|
||||
It checks C<< $ENV{TZ} >> for a valid time zone name.
|
||||
|
||||
=item * Windows Registry
|
||||
|
||||
When using the registry, we look for the Windows time zone and use a
|
||||
mapping to translate this to an IANA time zone name.
|
||||
|
||||
=over 8
|
||||
|
||||
=item * Windows Vista, 2008 Server and newer Windows operating systems
|
||||
|
||||
We look in "SYSTEM/CurrentControlSet/Control/TimeZoneInformation/" for
|
||||
a node named "/TimeZoneKeyName". If this exists, we use this key to
|
||||
look up the IANA time zone name in our mapping.
|
||||
|
||||
=item * Windows NT, Windows 2000, Windows XP, Windows 2003 Server
|
||||
|
||||
We look in "SOFTWARE/Microsoft/Windows NT/CurrentVersion/Time Zones/"
|
||||
and loop through all of its sub keys.
|
||||
|
||||
For each sub key, we compare the value of the key with "/Std" appended
|
||||
to the end to the value of
|
||||
"SYSTEM/CurrentControlSet/Control/TimeZoneInformation/StandardName". This
|
||||
gives us the I<English> name of the Windows time zone, which we use to
|
||||
look up the IANA time zone name.
|
||||
|
||||
=item * Windows 95, Windows 98, Windows Millenium Edition
|
||||
|
||||
The algorithm is the same as for NT, but we loop through the sub keys
|
||||
of "SOFTWARE/Microsoft/Windows/CurrentVersion/Time Zones/"
|
||||
|
||||
=back
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
David Pinkowitz <dapink@cpan.org>
|
||||
|
||||
=item *
|
||||
|
||||
Dave Rolsky <autarch@urth.org>
|
||||
|
||||
=back
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (C) 2007-2014 Dave Rolsky <autarch@urth.org>
|
||||
Copyright (C) 2014-2019 by David Pinkowitz <dapink@cpan.org>
|
||||
|
||||
This is free software; you can redistribute it and/or modify it under
|
||||
the same terms as the Perl 5 programming language system itself.
|
||||
|
||||
=cut
|
||||
Reference in New Issue
Block a user