DateTime::TimeZone::Catalog::Extend - Extend DateTime::TimeZone catalog
use DateTime::TimeZone; # After DateTime::TimeZone is loaded, let's extend it use DateTime::TimeZone::Catalog::Extend; # That's it; nothing more # This would normally trigger an exception, but not anymore my $tz = DateTime::TimeZone->new( name => 'JST' ); # Get the list of all aliases my $aliases = DateTime::TimeZone::Catalog::Extend->aliases; my $map = DateTime::TimeZone::Catalog::Extend->zone_map; my $fmt = DateTime::Format::Strptime->new( pattern => $pattern, zone_map => $map, ); my $dt = $fmt->parse_datetime( $str ); die( $fmt->errmsg ) if( !defined( $dt ) );
v0.3.0
This is a very simple module based on the list of time zone aliases that are sometimes found in dates.
Upon using this module, it will add to the DateTime::TimeZone::Catalog those aliases with their corresponding time zone offset. When there is more than one time zone offset in the list, only the first one is set.
Here is the list of those time zone aliases and their offset:
A
ACDT
ACST
ACT
ACWST
ADT
AEDT
AES
AEST
AET
AFT
AHDT
AHST
AKDT
AKST
ALMT
AMST
AMT
ANAST
ANAT
AQTT
ART
AST
AT
AWST
AZOST
AZOT
AZST
AZT
B
BADT
BAT
BDST
BDT
BET
BIOT
BIT
BNT
BORT
BOT
BRA
BRST
BRT
BST
BTT
C
CAST
CAT
CCT
CDT
CEST
CET
CETDST
CHADT
CHAST
CHOST
CHOT
CHST
CHUT
CIST
CKT
CLST
CLT
COST
COT
CST
CSuT
CT
CUT
CVT
CWST
CXT
ChST
D
DAVT
DDUT
DFT
DNT
DST
E
EASST
EAST
EAT
ECT
EDT
EEST
EET
EETDST
EGST
EGT
EMT
EST
ESuT
ET
F
FET
FJST
FJT
FKST
FKT
FNT
FWT
G
GALT
GAMT
GEST
GET
GFT
GILT
GIT
GMT
GST
GT
GYT
GZ
H
HAA
HAC
HAE
HAEC
HAP
HAR
HAT
HAY
HDT
HFE
HFH
HG
HKT
HL
HMT
HNA
HNC
HNE
HNP
HNR
HNT
HNY
HOE
HOVST
HOVT
HST
I
ICT
IDLE
IDLW
IDT
IOT
IRDT
IRKST
IRKT
IRST
IRT
IST
IT
ITA
JAVT
JAYT
JST
JT
K
KALT
KDT
KGST
KGT
KOST
KRAST
KRAT
KST
L
LHDT
LHST
LIGT
LINT
LKT
LST
LT
M
MAGST
MAGT
MAL
MART
MAT
MAWT
MDT
MED
MEDST
MEST
MESZ
MET
MEWT
MEX
MEZ
MHT
MIST
MIT
MMT
MPT
MSD
MSK
MSKS
MST
MT
MUT
MVT
MYT
N
NCT
NDT
NFT
NOR
NOVST
NOVT
NPT
NRT
NST
NSUT
NT
NUT
NZDT
NZST
NZT
O
OESZ
OEZ
OMSST
OMST
ORAT
OZ
P
PDT
PET
PETST
PETT
PGT
PHOT
PHST
PHT
PKT
PMDT
PMST
PMT
PNT
PONT
PST
PWT
PYST
PYT
Q
R
R1T
R2T
RET
ROK
ROTT
S
SADT
SAKT
SAMT
SAST
SBT
SCT
SDT
SET
SGT
SLST
SRET
SRT
SST
SWT
SYOT
T
TAHT
TFT
THA
THAT
TJT
TKT
TLT
TMT
TOT
TRT
TRUT
TST
TUC
TVT
U
ULAST
ULAT
USZ1
USZ1S
USZ3
USZ3S
USZ4
USZ4S
USZ5
USZ5S
USZ6
USZ6S
USZ7
USZ7S
USZ8
USZ8S
USZ9
USZ9S
UTC
UTZ
UYST
UYT
UZ10
UZ10S
UZ11
UZ11S
UZ12
UZ12S
UZT
V
VET
VLAST
VLAT
VOLT
VOST
VTZ
VUT
W
WAKT
WAST
WAT
WEST
WESZ
WET
WETDST
WEZ
WFT
WGST
WGT
WIB
WIT
WITA
WST
WTZ
WUT
X
Y
YAKST
YAKT
YAPT
YDT
YEKST
YEKT
YST
Z
Returns an array reference of the time zone aliases.
my $aliases = DateTime::TimeZone::Catalog::Extend->aliases;
You can also achieve the same result by accessing directly the package variable $ALIAS_CATALOG
$ALIAS_CATALOG
my $aliases = [sort( keys( %$DateTime::TimeZone::Catalog::Extend::ALIAS_CATALOG ) )];
Returns an hash reference of time zone alias to their offset. This class function caches the hash reference so the second time it returns the cached value.
The returned hash reference is suitable to be passed to "new" in DateTime::Format::Strptime with the argument zone_map
zone_map
my $str = 'Fri Mar 25 2011 12:16:25 ADT'; my $map = DateTime::TimeZone::Catalog::Extend->zone_map; my $fmt = DateTime::Format::Strptime->new( pattern => $pattern, zone_map => $map, ); my $dt = $fmt->parse_datetime( $str ); die( $fmt->errmsg ) if( !defined( $dt ) );
Without passing the zone_map, DateTime::Format::Strptime would have returned the error c<The time zone abbreviation that was parsed is ambiguous>
Jacques Deguest <jack@deguest.jp>
DateTime::TimeZone::Catalog, DateTime::TimeZone::Alias, DateTime::TimeZone
Copyright(c) 2022 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install DateTime::TimeZone::Catalog::Extend, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DateTime::TimeZone::Catalog::Extend
CPAN shell
perl -MCPAN -e shell install DateTime::TimeZone::Catalog::Extend
For more information on module installation, please visit the detailed CPAN module installation guide.