line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ============================================================================ |
2
|
|
|
|
|
|
|
package DateTime::Format::CLDR; |
3
|
|
|
|
|
|
|
# ============================================================================ |
4
|
16
|
|
|
16
|
|
1314418
|
use strict; |
|
16
|
|
|
|
|
36
|
|
|
16
|
|
|
|
|
439
|
|
5
|
16
|
|
|
16
|
|
84
|
use warnings; |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
471
|
|
6
|
16
|
|
|
16
|
|
8084
|
use utf8; |
|
16
|
|
|
|
|
108
|
|
|
16
|
|
|
|
|
92
|
|
7
|
|
|
|
|
|
|
|
8
|
16
|
|
|
16
|
|
13294
|
use DateTime; |
|
16
|
|
|
|
|
1551985
|
|
|
16
|
|
|
|
|
593
|
|
9
|
16
|
|
|
16
|
|
122
|
use DateTime::Locale 0.4000; |
|
16
|
|
|
|
|
449
|
|
|
16
|
|
|
|
|
351
|
|
10
|
16
|
|
|
16
|
|
81
|
use DateTime::TimeZone; |
|
16
|
|
|
|
|
28
|
|
|
16
|
|
|
|
|
434
|
|
11
|
16
|
|
|
16
|
|
78
|
use Params::Validate qw( validate_pos validate SCALAR BOOLEAN OBJECT CODEREF ); |
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
1350
|
|
12
|
16
|
|
|
16
|
|
82
|
use Exporter; |
|
16
|
|
|
|
|
31
|
|
|
16
|
|
|
|
|
559
|
|
13
|
16
|
|
|
16
|
|
80
|
use Carp qw(croak carp); |
|
16
|
|
|
|
|
29
|
|
|
16
|
|
|
|
|
799
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Export functions |
16
|
16
|
|
|
16
|
|
188
|
use base qw(Exporter); |
|
16
|
|
|
|
|
34
|
|
|
16
|
|
|
|
|
108743
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw( cldr_format cldr_parse ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# CPAN data |
20
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:MAROS'; |
21
|
|
|
|
|
|
|
our $VERSION = '1.17'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Default format if none is set |
24
|
|
|
|
|
|
|
our $DEFAULT_FORMAT = 'date_format_medium'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Simple regexp blocks |
27
|
|
|
|
|
|
|
our %PARTS = ( |
28
|
|
|
|
|
|
|
year_long => qr/(-?\d{1,4})/o, |
29
|
|
|
|
|
|
|
year_short => qr/(-?\d{2})/o, |
30
|
|
|
|
|
|
|
day_week => qr/([1-7])/o, |
31
|
|
|
|
|
|
|
day_month => qr/(3[01]|[12]\d|0?[1-9])/o, |
32
|
|
|
|
|
|
|
day_year => qr/([1-3]\d\d|0?[1-9]\d|(?:00)?[1-9])/o, |
33
|
|
|
|
|
|
|
month => qr/(1[0-2]|0?[1-9])/o, |
34
|
|
|
|
|
|
|
hour_23 => qr/(00|2[0-4]|1\d|0?\d)/o, |
35
|
|
|
|
|
|
|
hour_24 => qr/(2[0-4]|1\d|0?[1-9])/o, |
36
|
|
|
|
|
|
|
hour_12 => qr/(1[0-2]|0?[1-9])/o, |
37
|
|
|
|
|
|
|
hour_11 => qr/(00|1[01]|0?\d)/o, |
38
|
|
|
|
|
|
|
minute => qr/([0-5]?\d)/o, |
39
|
|
|
|
|
|
|
second => qr/(6[01]|[0-5]?\d)/o, |
40
|
|
|
|
|
|
|
quarter => qr/([1-4])/o, |
41
|
|
|
|
|
|
|
week_year => qr/(5[0-3]|[1-4]\d|0?[1-9])/o, |
42
|
|
|
|
|
|
|
week_month => qr/(\d)/o, |
43
|
|
|
|
|
|
|
#timezone => qr/[+-](1[0-4]|0?\d)(00|15|30|45)/o, |
44
|
|
|
|
|
|
|
number => qr/(\d+)/o, |
45
|
|
|
|
|
|
|
timezone2 => qr/([A-Z1-9a-z]+)([+-](?:1[0-4]|0\d)(?:00|15|30|45))/o, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Table for mapping abbreviated timezone names to offsets |
49
|
|
|
|
|
|
|
our %ZONEMAP = ( |
50
|
|
|
|
|
|
|
'A' => '+0100', 'ACDT' => '+1030', 'ACST' => '+0930', |
51
|
|
|
|
|
|
|
'ADT' => 'Ambiguous', 'AEDT' => '+1100', 'AES' => '+1000', |
52
|
|
|
|
|
|
|
'AEST' => '+1000', 'AFT' => '+0430', 'AHDT' => '-0900', |
53
|
|
|
|
|
|
|
'AHST' => '-1000', 'AKDT' => '-0800', 'AKST' => '-0900', |
54
|
|
|
|
|
|
|
'AMST' => '+0400', 'AMT' => '+0400', 'ANAST' => '+1300', |
55
|
|
|
|
|
|
|
'ANAT' => '+1200', 'ART' => '-0300', 'AST' => 'Ambiguous', |
56
|
|
|
|
|
|
|
'AT' => '-0100', 'AWST' => '+0800', 'AZOST' => '+0000', |
57
|
|
|
|
|
|
|
'AZOT' => '-0100', 'AZST' => '+0500', 'AZT' => '+0400', |
58
|
|
|
|
|
|
|
'B' => '+0200', 'BADT' => '+0400', 'BAT' => '+0600', |
59
|
|
|
|
|
|
|
'BDST' => '+0200', 'BDT' => '+0600', 'BET' => '-1100', |
60
|
|
|
|
|
|
|
'BNT' => '+0800', 'BORT' => '+0800', 'BOT' => '-0400', |
61
|
|
|
|
|
|
|
'BRA' => '-0300', 'BST' => 'Ambiguous', 'BT' => 'Ambiguous', |
62
|
|
|
|
|
|
|
'BTT' => '+0600', 'C' => '+0300', 'CAST' => '+0930', |
63
|
|
|
|
|
|
|
'CAT' => 'Ambiguous', 'CCT' => 'Ambiguous', 'CDT' => 'Ambiguous', |
64
|
|
|
|
|
|
|
'CEST' => '+0200', 'CET' => '+0100', 'CETDST' => '+0200', |
65
|
|
|
|
|
|
|
'CHADT' => '+1345', 'CHAST' => '+1245', 'CKT' => '-1000', |
66
|
|
|
|
|
|
|
'CLST' => '-0300', 'CLT' => '-0400', 'COT' => '-0500', |
67
|
|
|
|
|
|
|
'CST' => 'Ambiguous', 'CSuT' => '+1030', 'CUT' => '+0000', |
68
|
|
|
|
|
|
|
'CVT' => '-0100', 'CXT' => '+0700', 'ChST' => '+1000', |
69
|
|
|
|
|
|
|
'D' => '+0400', 'DAVT' => '+0700', 'DDUT' => '+1000', |
70
|
|
|
|
|
|
|
'DNT' => '+0100', 'DST' => '+0200', 'E' => '+0500', |
71
|
|
|
|
|
|
|
'EASST' => '-0500', 'EAST' => 'Ambiguous', 'EAT' => '+0300', |
72
|
|
|
|
|
|
|
'ECT' => 'Ambiguous', 'EDT' => 'Ambiguous', 'EEST' => '+0300', |
73
|
|
|
|
|
|
|
'EET' => '+0200', 'EETDST' => '+0300', 'EGST' => '+0000', |
74
|
|
|
|
|
|
|
'EGT' => '-0100', 'EMT' => '+0100', 'EST' => 'Ambiguous', |
75
|
|
|
|
|
|
|
'ESuT' => '+1100', 'F' => '+0600', 'FDT' => 'Ambiguous', |
76
|
|
|
|
|
|
|
'FJST' => '+1300', 'FJT' => '+1200', 'FKST' => '-0300', |
77
|
|
|
|
|
|
|
'FKT' => '-0400', 'FST' => 'Ambiguous', 'FWT' => '+0100', |
78
|
|
|
|
|
|
|
'G' => '+0700', 'GALT' => '-0600', 'GAMT' => '-0900', |
79
|
|
|
|
|
|
|
'GEST' => '+0500', 'GET' => '+0400', 'GFT' => '-0300', |
80
|
|
|
|
|
|
|
'GILT' => '+1200', 'GMT' => '+0000', 'GST' => 'Ambiguous', |
81
|
|
|
|
|
|
|
'GT' => '+0000', 'GYT' => '-0400', 'GZ' => '+0000', |
82
|
|
|
|
|
|
|
'H' => '+0800', 'HAA' => '-0300', 'HAC' => '-0500', |
83
|
|
|
|
|
|
|
'HAE' => '-0400', 'HAP' => '-0700', 'HAR' => '-0600', |
84
|
|
|
|
|
|
|
'HAT' => '-0230', 'HAY' => '-0800', 'HDT' => '-0930', |
85
|
|
|
|
|
|
|
'HFE' => '+0200', 'HFH' => '+0100', 'HG' => '+0000', |
86
|
|
|
|
|
|
|
'HKT' => '+0800', 'HL' => 'local', 'HNA' => '-0400', |
87
|
|
|
|
|
|
|
'HNC' => '-0600', 'HNE' => '-0500', 'HNP' => '-0800', |
88
|
|
|
|
|
|
|
'HNR' => '-0700', 'HNT' => '-0330', 'HNY' => '-0900', |
89
|
|
|
|
|
|
|
'HOE' => '+0100', 'HST' => '-1000', 'I' => '+0900', |
90
|
|
|
|
|
|
|
'ICT' => '+0700', 'IDLE' => '+1200', 'IDLW' => '-1200', |
91
|
|
|
|
|
|
|
'IDT' => 'Ambiguous', 'IOT' => '+0500', 'IRDT' => '+0430', |
92
|
|
|
|
|
|
|
'IRKST' => '+0900', 'IRKT' => '+0800', 'IRST' => '+0430', |
93
|
|
|
|
|
|
|
'IRT' => '+0330', 'IST' => 'Ambiguous', 'IT' => '+0330', |
94
|
|
|
|
|
|
|
'ITA' => '+0100', 'JAVT' => '+0700', 'JAYT' => '+0900', |
95
|
|
|
|
|
|
|
'JST' => '+0900', 'JT' => '+0700', 'K' => '+1000', |
96
|
|
|
|
|
|
|
'KDT' => '+1000', 'KGST' => '+0600', 'KGT' => '+0500', |
97
|
|
|
|
|
|
|
'KOST' => '+1200', 'KRAST' => '+0800', 'KRAT' => '+0700', |
98
|
|
|
|
|
|
|
'KST' => '+0900', 'L' => '+1100', 'LHDT' => '+1100', |
99
|
|
|
|
|
|
|
'LHST' => '+1030', 'LIGT' => '+1000', 'LINT' => '+1400', |
100
|
|
|
|
|
|
|
'LKT' => '+0600', 'LST' => 'local', 'LT' => 'local', |
101
|
|
|
|
|
|
|
'M' => '+1200', 'MAGST' => '+1200', 'MAGT' => '+1100', |
102
|
|
|
|
|
|
|
'MAL' => '+0800', 'MART' => '-0930', 'MAT' => '+0300', |
103
|
|
|
|
|
|
|
'MAWT' => '+0600', 'MDT' => '-0600', 'MED' => '+0200', |
104
|
|
|
|
|
|
|
'MEDST' => '+0200', 'MEST' => '+0200', 'MESZ' => '+0200', |
105
|
|
|
|
|
|
|
'MET' => 'Ambiguous', 'MEWT' => '+0100', 'MEX' => '-0600', |
106
|
|
|
|
|
|
|
'MEZ' => '+0100', 'MHT' => '+1200', 'MMT' => '+0630', |
107
|
|
|
|
|
|
|
'MPT' => '+1000', 'MSD' => '+0400', 'MSK' => '+0300', |
108
|
|
|
|
|
|
|
'MSKS' => '+0400', 'MST' => '-0700', 'MT' => '+0830', |
109
|
|
|
|
|
|
|
'MUT' => '+0400', 'MVT' => '+0500', 'MYT' => '+0800', |
110
|
|
|
|
|
|
|
'N' => '-0100', 'NCT' => '+1100', 'NDT' => '-0230', |
111
|
|
|
|
|
|
|
'NFT' => 'Ambiguous', 'NOR' => '+0100', 'NOVST' => '+0700', |
112
|
|
|
|
|
|
|
'NOVT' => '+0600', 'NPT' => '+0545', 'NRT' => '+1200', |
113
|
|
|
|
|
|
|
'NST' => 'Ambiguous', 'NSUT' => '+0630', 'NT' => '-1100', |
114
|
|
|
|
|
|
|
'NUT' => '-1100', 'NZDT' => '+1300', 'NZST' => '+1200', |
115
|
|
|
|
|
|
|
'NZT' => '+1200', 'O' => '-0200', 'OESZ' => '+0300', |
116
|
|
|
|
|
|
|
'OEZ' => '+0200', 'OMSST' => '+0700', 'OMST' => '+0600', |
117
|
|
|
|
|
|
|
'OZ' => 'local', 'P' => '-0300', 'PDT' => '-0700', |
118
|
|
|
|
|
|
|
'PET' => '-0500', 'PETST' => '+1300', 'PETT' => '+1200', |
119
|
|
|
|
|
|
|
'PGT' => '+1000', 'PHOT' => '+1300', 'PHT' => '+0800', |
120
|
|
|
|
|
|
|
'PKT' => '+0500', 'PMDT' => '-0200', 'PMT' => '-0300', |
121
|
|
|
|
|
|
|
'PNT' => '-0830', 'PONT' => '+1100', 'PST' => 'Ambiguous', |
122
|
|
|
|
|
|
|
'PWT' => '+0900', 'PYST' => '-0300', 'PYT' => '-0400', |
123
|
|
|
|
|
|
|
'Q' => '-0400', 'R' => '-0500', 'R1T' => '+0200', |
124
|
|
|
|
|
|
|
'R2T' => '+0300', 'RET' => '+0400', 'ROK' => '+0900', |
125
|
|
|
|
|
|
|
'S' => '-0600', 'SADT' => '+1030', 'SAST' => 'Ambiguous', |
126
|
|
|
|
|
|
|
'SBT' => '+1100', 'SCT' => '+0400', 'SET' => '+0100', |
127
|
|
|
|
|
|
|
'SGT' => '+0800', 'SRT' => '-0300', 'SST' => 'Ambiguous', |
128
|
|
|
|
|
|
|
'SWT' => '+0100', 'T' => '-0700', 'TFT' => '+0500', |
129
|
|
|
|
|
|
|
'THA' => '+0700', 'THAT' => '-1000', 'TJT' => '+0500', |
130
|
|
|
|
|
|
|
'TKT' => '-1000', 'TMT' => '+0500', 'TOT' => '+1300', |
131
|
|
|
|
|
|
|
'TRUT' => '+1000', 'TST' => '+0300', 'TUC ' => '+0000', |
132
|
|
|
|
|
|
|
'TVT' => '+1200', 'U' => '-0800', 'ULAST' => '+0900', |
133
|
|
|
|
|
|
|
'ULAT' => '+0800', 'USZ1' => '+0200', 'USZ1S' => '+0300', |
134
|
|
|
|
|
|
|
'USZ3' => '+0400', 'USZ3S' => '+0500', 'USZ4' => '+0500', |
135
|
|
|
|
|
|
|
'USZ4S' => '+0600', 'USZ5' => '+0600', 'USZ5S' => '+0700', |
136
|
|
|
|
|
|
|
'USZ6' => '+0700', 'USZ6S' => '+0800', 'USZ7' => '+0800', |
137
|
|
|
|
|
|
|
'USZ7S' => '+0900', 'USZ8' => '+0900', 'USZ8S' => '+1000', |
138
|
|
|
|
|
|
|
'USZ9' => '+1000', 'USZ9S' => '+1100', 'UTZ' => '-0300', |
139
|
|
|
|
|
|
|
'UYT' => '-0300', 'UZ10' => '+1100', 'UZ10S' => '+1200', |
140
|
|
|
|
|
|
|
'UZ11' => '+1200', 'UZ11S' => '+1300', 'UZ12' => '+1200', |
141
|
|
|
|
|
|
|
'UZ12S' => '+1300', 'UZT' => '+0500', 'V' => '-0900', |
142
|
|
|
|
|
|
|
'VET' => '-0400', 'VLAST' => '+1100', 'VLAT' => '+1000', |
143
|
|
|
|
|
|
|
'VTZ' => '-0200', 'VUT' => '+1100', 'W' => '-1000', |
144
|
|
|
|
|
|
|
'WAKT' => '+1200', 'WAST' => 'Ambiguous', 'WAT' => '+0100', |
145
|
|
|
|
|
|
|
'WEST' => '+0100', 'WESZ' => '+0100', 'WET' => '+0000', |
146
|
|
|
|
|
|
|
'WETDST' => '+0100', 'WEZ' => '+0000', 'WFT' => '+1200', |
147
|
|
|
|
|
|
|
'WGST' => '-0200', 'WGT' => '-0300', 'WIB' => '+0700', |
148
|
|
|
|
|
|
|
'WIT' => '+0900', 'WITA' => '+0800', 'WST' => 'Ambiguous', |
149
|
|
|
|
|
|
|
'WTZ' => '-0100', 'WUT' => '+0100', 'X' => '-1100', |
150
|
|
|
|
|
|
|
'Y' => '-1200', 'YAKST' => '+1000', 'YAKT' => '+0900', |
151
|
|
|
|
|
|
|
'YAPT' => '+1000', 'YDT' => '-0800', 'YEKST' => '+0600', |
152
|
|
|
|
|
|
|
'YEKT' => '+0500', 'YST' => '-0900', 'Z' => '+0000', |
153
|
|
|
|
|
|
|
); |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# Map of CLDR commands to values |
156
|
|
|
|
|
|
|
# Value might be |
157
|
|
|
|
|
|
|
# - Regular expression: usually taken from %PART |
158
|
|
|
|
|
|
|
# - String: DateTime::Locale method names. Method must retun lists of valid values |
159
|
|
|
|
|
|
|
# - Arrayref: List of valid values |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
our %PARSER = ( |
162
|
|
|
|
|
|
|
G1 => 'era_abbreviated', |
163
|
|
|
|
|
|
|
G4 => 'era_wide', |
164
|
|
|
|
|
|
|
G5 => 'era_narrow', |
165
|
|
|
|
|
|
|
y1 => $PARTS{year_long}, |
166
|
|
|
|
|
|
|
y2 => $PARTS{year_short}, |
167
|
|
|
|
|
|
|
y3 => qr/(-?\d{3,4})/o, |
168
|
|
|
|
|
|
|
y4 => qr/(-?\d{4})/o, |
169
|
|
|
|
|
|
|
y5 => qr/(-?\d{5})/o, |
170
|
|
|
|
|
|
|
Y1 => $PARTS{year_long}, |
171
|
|
|
|
|
|
|
u1 => $PARTS{year_long}, |
172
|
|
|
|
|
|
|
Q1 => $PARTS{quarter}, |
173
|
|
|
|
|
|
|
Q3 => 'quarter_format_abbreviated', |
174
|
|
|
|
|
|
|
Q4 => 'quarter_format_wide', |
175
|
|
|
|
|
|
|
q1 => $PARTS{quarter}, |
176
|
|
|
|
|
|
|
q3 => 'quarter_stand_alone_abbreviated', |
177
|
|
|
|
|
|
|
q4 => 'quarter_stand_alone_wide', |
178
|
|
|
|
|
|
|
M1 => $PARTS{month}, |
179
|
|
|
|
|
|
|
M3 => 'month_format_abbreviated', |
180
|
|
|
|
|
|
|
M4 => 'month_format_wide', |
181
|
|
|
|
|
|
|
M5 => 'month_format_narrow', |
182
|
|
|
|
|
|
|
L1 => $PARTS{month}, |
183
|
|
|
|
|
|
|
L3 => 'month_stand_alone_abbreviated', |
184
|
|
|
|
|
|
|
L4 => 'month_stand_alone_wide', |
185
|
|
|
|
|
|
|
L5 => 'month_stand_alone_narrow', |
186
|
|
|
|
|
|
|
w1 => $PARTS{week_year}, |
187
|
|
|
|
|
|
|
W1 => $PARTS{week_month}, |
188
|
|
|
|
|
|
|
d1 => $PARTS{day_month}, |
189
|
|
|
|
|
|
|
D1 => $PARTS{day_year}, |
190
|
|
|
|
|
|
|
F1 => $PARTS{week_month}, |
191
|
|
|
|
|
|
|
E1 => 'day_format_abbreviated', |
192
|
|
|
|
|
|
|
E4 => 'day_format_wide', |
193
|
|
|
|
|
|
|
E5 => 'day_format_narrow', |
194
|
|
|
|
|
|
|
e1 => $PARTS{day_week}, |
195
|
|
|
|
|
|
|
e3 => 'day_format_abbreviated', |
196
|
|
|
|
|
|
|
e4 => 'day_format_wide', |
197
|
|
|
|
|
|
|
e5 => 'day_format_narrow', |
198
|
|
|
|
|
|
|
c1 => $PARTS{day_week}, |
199
|
|
|
|
|
|
|
c3 => 'day_stand_alone_abbreviated', |
200
|
|
|
|
|
|
|
c4 => 'day_stand_alone_wide', |
201
|
|
|
|
|
|
|
c5 => 'day_stand_alone_narrow', |
202
|
|
|
|
|
|
|
a1 => 'am_pm_abbreviated', |
203
|
|
|
|
|
|
|
h1 => $PARTS{hour_12}, |
204
|
|
|
|
|
|
|
H1 => $PARTS{hour_23}, |
205
|
|
|
|
|
|
|
K1 => $PARTS{hour_11}, |
206
|
|
|
|
|
|
|
k1 => $PARTS{hour_24}, |
207
|
|
|
|
|
|
|
#j1 => Handled dyamically, |
208
|
|
|
|
|
|
|
m1 => $PARTS{minute}, |
209
|
|
|
|
|
|
|
s1 => $PARTS{second}, |
210
|
|
|
|
|
|
|
S1 => $PARTS{number}, #! |
211
|
|
|
|
|
|
|
Z1 => [ grep { $_ ne 'Ambiguous' } values %ZONEMAP ], |
212
|
|
|
|
|
|
|
Z4 => $PARTS{timezone2}, |
213
|
|
|
|
|
|
|
z1 => [ keys %ZONEMAP ], |
214
|
|
|
|
|
|
|
z4 => [ DateTime::TimeZone->all_names ], |
215
|
|
|
|
|
|
|
); |
216
|
|
|
|
|
|
|
$PARSER{v1} = $PARSER{V1} = $PARSER{z1}; |
217
|
|
|
|
|
|
|
$PARSER{v4} = $PARSER{V4} = $PARSER{z4}; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=encoding utf8 |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 NAME |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
DateTime::Format::CLDR - Parse and format CLDR time patterns |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 SYNOPSIS |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
use DateTime::Format::CLDR; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# 1. Basic example |
231
|
|
|
|
|
|
|
my $cldr1 = DateTime::Format::CLDR->new( |
232
|
|
|
|
|
|
|
pattern => 'HH:mm:ss', |
233
|
|
|
|
|
|
|
locale => 'de_AT', |
234
|
|
|
|
|
|
|
time_zone => 'Europe/Vienna', |
235
|
|
|
|
|
|
|
); |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
my $dt1 = $cldr1->parse_datetime('23:16:42'); |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
print $cldr1->format_datetime($dt1); |
240
|
|
|
|
|
|
|
# 23:16:42 |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# 2. Get pattern from selected locale |
243
|
|
|
|
|
|
|
# pattern is taken from 'date_format_medium' in DateTime::Locale::de_AT |
244
|
|
|
|
|
|
|
my $cldr2 = DateTime::Format::CLDR->new( |
245
|
|
|
|
|
|
|
locale => 'de_AT', |
246
|
|
|
|
|
|
|
); |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
print $cldr2->parse_datetime('23.11.2007'); |
249
|
|
|
|
|
|
|
# 2007-11-23T00:00:00 |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# 3. Croak when things go wrong |
252
|
|
|
|
|
|
|
my $cldr3 = DateTime::Format::CLDR->new( |
253
|
|
|
|
|
|
|
locale => 'de_AT', |
254
|
|
|
|
|
|
|
on_error => 'croak', |
255
|
|
|
|
|
|
|
); |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
$cldr3->parse_datetime('23.33.2007'); |
258
|
|
|
|
|
|
|
# Croaks |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# 4. Use DateTime::Locale |
261
|
|
|
|
|
|
|
my $locale = DateTime::Locale->load('en_GB'); |
262
|
|
|
|
|
|
|
my $cldr4 = DateTime::Format::CLDR->new( |
263
|
|
|
|
|
|
|
pattern => $locale->datetime_format_medium, |
264
|
|
|
|
|
|
|
locale => $locale, |
265
|
|
|
|
|
|
|
); |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
print $cldr4->parse_datetime('22 Dec 1995 09:05:02'); |
268
|
|
|
|
|
|
|
# 1995-12-22T09:05:02 |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head1 DESCRIPTION |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
This module provides a parser (and also a formater) for datetime strings |
273
|
|
|
|
|
|
|
using patterns as defined by the Unicode CLDR Project |
274
|
|
|
|
|
|
|
(Common Locale Data Repository). L. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
CLDR format is supported by L and L starting with |
277
|
|
|
|
|
|
|
version 0.40. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head1 METHODS |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=head2 Constructor |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=head3 new |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
DateTime::Format::CLDR->new(%PARAMS); |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
The following parameters are used by DateTime::Format::CLDR: |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=over |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item * locale |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
Locale. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
See L accessor. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=item * pattern (optional) |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
CLDR pattern. If you don't provide a pattern the C |
300
|
|
|
|
|
|
|
pattern from L for the selected locale will be used. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
See L accessor. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=item * time_zone (optional) |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
Timezone that should be used by default. If your pattern contains |
307
|
|
|
|
|
|
|
timezone information this attribute will be ignored. |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
See L accessor. |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=item * on_error (optional) |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
Set the error behaviour. |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
See L accessor. |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
=item * incomplete (optional) |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
Set the behaviour how to handle incomplete date information. |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
See L accessor. |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=back |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=cut |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
sub new { |
328
|
98
|
|
|
98
|
1
|
112037
|
my $class = shift; |
329
|
98
|
|
|
|
|
3694
|
my %args = validate( @_, { |
330
|
|
|
|
|
|
|
locale => { type => SCALAR | OBJECT, default => 'en' }, |
331
|
|
|
|
|
|
|
pattern => { type => SCALAR, optional => 1 }, |
332
|
|
|
|
|
|
|
time_zone => { type => SCALAR | OBJECT, optional => 1 }, |
333
|
|
|
|
|
|
|
on_error => { type => SCALAR | CODEREF, optional => 1, default => 'undef' }, |
334
|
|
|
|
|
|
|
incomplete => { type => SCALAR | CODEREF, optional => 1, default => 1 }, |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
); |
337
|
|
|
|
|
|
|
|
338
|
98
|
|
|
|
|
866
|
my $self = bless \%args, $class; |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
# Set default values |
341
|
98
|
|
66
|
|
|
698
|
$args{time_zone} ||= DateTime::TimeZone->new( name => 'floating' ); |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
# Pass on to accessors |
344
|
98
|
|
|
|
|
3464
|
$self->time_zone($args{time_zone}); |
345
|
98
|
|
|
|
|
365
|
$self->locale($args{locale}); |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
# Set default values |
348
|
98
|
100
|
|
|
|
574
|
unless (defined $args{pattern}) { |
349
|
6
|
50
|
|
|
|
20
|
if ($self->locale->can($DEFAULT_FORMAT)) { |
350
|
6
|
|
|
|
|
16
|
$args{pattern} = $self->locale->$DEFAULT_FORMAT; |
351
|
|
|
|
|
|
|
} else { |
352
|
0
|
|
|
|
|
0
|
croak("Method '$DEFAULT_FORMAT' not available in ".ref($self->loclale)); |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
|
356
|
98
|
|
|
|
|
358
|
$self->pattern($args{pattern}); |
357
|
98
|
|
|
|
|
314
|
$self->on_error($args{on_error}); |
358
|
98
|
|
|
|
|
303
|
$self->incomplete($args{incomplete}); |
359
|
98
|
|
|
|
|
196
|
$self->{errmsg} = undef; |
360
|
|
|
|
|
|
|
|
361
|
98
|
|
|
|
|
349
|
return $self; |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=head2 Accessors |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
=head3 pattern |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
Get/set CLDR pattern. See L<"CLDR PATTERNS"> or L |
369
|
|
|
|
|
|
|
for details about patterns. |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
$cldr->pattern('d MMM y HH:mm:ss'); |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
It is possible to retrieve patterns from L |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
$dl = DateTime::Locale->load('es_AR'); |
376
|
|
|
|
|
|
|
$cldr->pattern($dl->datetime_format_full); |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=cut |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
sub pattern { |
381
|
113
|
|
|
113
|
1
|
5268
|
my ($self,$pattern) = @_; |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
# Set pattern |
384
|
113
|
100
|
|
|
|
291
|
if (defined $pattern) { |
385
|
99
|
|
|
|
|
184
|
$self->{pattern} = $pattern; |
386
|
99
|
|
|
|
|
173
|
undef $self->{_built_pattern}; |
387
|
|
|
|
|
|
|
} |
388
|
|
|
|
|
|
|
|
389
|
113
|
|
|
|
|
255
|
return $self->{pattern}; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=head3 time_zone |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
Get/set time_zone. Returns a C object. |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
Accepts either a timezone name or a C object. |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
$cldr->time_zone('America/Argentina/Mendoza'); |
399
|
|
|
|
|
|
|
OR |
400
|
|
|
|
|
|
|
my $tz = DateTime::TimeZone->new(name => 'America/Argentina/Mendoza'); |
401
|
|
|
|
|
|
|
$cldr->time_zone($tz); |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
=cut |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
sub time_zone { |
406
|
103
|
|
|
103
|
1
|
1879
|
my ($self,$time_zone) = @_; |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
# Set timezone |
409
|
103
|
100
|
|
|
|
307
|
if (defined $time_zone) { |
410
|
101
|
100
|
66
|
|
|
813
|
if (ref $time_zone |
411
|
|
|
|
|
|
|
&& $time_zone->isa('DateTime::TimeZone')) { |
412
|
94
|
|
|
|
|
250
|
$self->{time_zone} = $time_zone; |
413
|
|
|
|
|
|
|
} else { |
414
|
7
|
50
|
|
|
|
62
|
$self->{time_zone} = DateTime::TimeZone->new( name => $time_zone ) |
415
|
|
|
|
|
|
|
or croak("Could not create timezone from $time_zone"); |
416
|
|
|
|
|
|
|
} |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
|
419
|
101
|
|
|
|
|
64051
|
return $self->{time_zone}; |
420
|
|
|
|
|
|
|
} |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=head3 locale |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
Get/set a locale. Returns a C object. |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
Accepts either a locale name or a C object. |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
$cldr->locale('fr_CA'); |
429
|
|
|
|
|
|
|
OR |
430
|
|
|
|
|
|
|
$dl = DateTime::Locale->load('fr_CA'); |
431
|
|
|
|
|
|
|
$cldr->locale($dl); |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=cut |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
sub locale { |
436
|
114
|
|
|
114
|
1
|
1604
|
my ($self,$locale) = @_; |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
# Set locale |
439
|
114
|
100
|
|
|
|
325
|
if (defined $locale) { |
440
|
100
|
100
|
66
|
|
|
458
|
unless (ref $locale |
441
|
|
|
|
|
|
|
&& ($locale->isa('DateTime::Locale::Base') || $locale->isa('DateTime::Locale::FromData'))) { |
442
|
86
|
50
|
|
|
|
445
|
$self->{locale} = DateTime::Locale->load( $locale ) |
443
|
|
|
|
|
|
|
or croak("Could not create locale from $locale"); |
444
|
|
|
|
|
|
|
} else { |
445
|
14
|
|
|
|
|
33
|
$self->{locale} = $locale; |
446
|
|
|
|
|
|
|
} |
447
|
99
|
|
|
|
|
21924
|
undef $self->{_built_pattern}; |
448
|
|
|
|
|
|
|
} |
449
|
|
|
|
|
|
|
|
450
|
113
|
|
|
|
|
296
|
return $self->{locale}; |
451
|
|
|
|
|
|
|
} |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
=head3 on_error |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
Get/set the error behaviour. |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
Accepts the following values |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
=over |
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=item * 'undef' (Literal) (default) |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
Returns undef on error and sets L |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=item * 'croak' |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
Croak on error |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=item * CODEREF |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
Run the given coderef on error. |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=back |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=cut |
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
sub on_error { |
478
|
100
|
|
|
100
|
1
|
685
|
my ($self,$on_error) = @_; |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
# Set locale |
481
|
100
|
100
|
|
|
|
286
|
if (defined $on_error) { |
482
|
99
|
100
|
100
|
|
|
831
|
croak("The value supplied to on_error must be either 'croak', 'undef' or a code reference.") |
|
|
|
100
|
|
|
|
|
483
|
|
|
|
|
|
|
unless ref($on_error) eq 'CODE' |
484
|
|
|
|
|
|
|
or $on_error eq 'croak' |
485
|
|
|
|
|
|
|
or $on_error eq 'undef'; |
486
|
98
|
|
|
|
|
254
|
return $self->{on_error}; |
487
|
|
|
|
|
|
|
} |
488
|
1
|
|
|
|
|
5
|
return $self->{on_error}; |
489
|
|
|
|
|
|
|
} |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
=head3 incomplete |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
Set the behaviour how to handle incomplete Date information. |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
Accepts the following values |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=over |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=item * '1' (default) |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
Sets the missing values to '1'. Thus if you only parse a time sting you would |
502
|
|
|
|
|
|
|
get '0001-01-01' as the date. |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=item * 'incomplete' |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
Create a L object instead. |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=item * CODEREF |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
Run the given coderef on incomplete values. The code reference will be |
511
|
|
|
|
|
|
|
called with the C object and a hash of parsed values |
512
|
|
|
|
|
|
|
as supplied to Cnew>. It should return a modified hash which |
513
|
|
|
|
|
|
|
will be passed to Cnew>. |
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=back |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=cut |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
sub incomplete { |
520
|
100
|
|
|
100
|
1
|
997
|
my ($self,$incomplete) = @_; |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
# Set locale |
523
|
100
|
100
|
|
|
|
234
|
if (defined $incomplete) { |
524
|
99
|
100
|
100
|
|
|
617
|
croak("The value supplied to incomplete must be either 'incomplete', '1' or a code reference.") |
|
|
|
100
|
|
|
|
|
525
|
|
|
|
|
|
|
unless ref($incomplete) eq 'CODE' |
526
|
|
|
|
|
|
|
or $incomplete eq '1' |
527
|
|
|
|
|
|
|
or $incomplete eq 'incomplete'; |
528
|
98
|
|
|
|
|
194
|
return $self->{incomplete}; |
529
|
|
|
|
|
|
|
} |
530
|
1
|
|
|
|
|
6
|
return $self->{incomplete}; |
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=head2 Public Methods |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=head3 parse_datetime |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
my $datetime = $cldr->parse_datetime($string); |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
Parses a string and returns a C object on success (If you provide |
540
|
|
|
|
|
|
|
incomplete data and set the L attribute accordingly it will |
541
|
|
|
|
|
|
|
return a C object). If the string cannot be parsed |
542
|
|
|
|
|
|
|
an error will be thrown (depending on the C attribute). |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
=cut |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
sub parse_datetime { |
547
|
17140
|
|
|
17140
|
1
|
13541628
|
my ( $self, $string ) = validate_pos( @_, 1, { type => SCALAR } ); |
548
|
|
|
|
|
|
|
|
549
|
17140
|
|
|
|
|
71946
|
my $pattern = $self->_build_pattern(); |
550
|
|
|
|
|
|
|
|
551
|
17140
|
|
|
|
|
27209
|
my $datetime_initial = $string; |
552
|
17140
|
|
|
|
|
31864
|
my %datetime_info = (); |
553
|
17140
|
|
|
|
|
24710
|
my %datetime_check = (); |
554
|
|
|
|
|
|
|
my $datetime_error = sub { |
555
|
7
|
|
|
7
|
|
15
|
my $occurence = shift; |
556
|
7
|
|
|
|
|
10
|
my $error = $datetime_initial; |
557
|
7
|
|
|
|
|
20
|
substr($error,(length($occurence) * -1),0," HERE-->"); |
558
|
7
|
|
|
|
|
33
|
return $self->_local_croak("Could not get datetime for $datetime_initial (Error marked by 'HERE-->'): '$error'"); |
559
|
17140
|
|
|
|
|
71380
|
}; |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
# Set default datetime values |
562
|
|
|
|
|
|
|
my %datetime = ( |
563
|
|
|
|
|
|
|
hour => 0, |
564
|
|
|
|
|
|
|
minute => 0, |
565
|
|
|
|
|
|
|
second => 0, |
566
|
|
|
|
|
|
|
time_zone => $self->{time_zone}, |
567
|
|
|
|
|
|
|
locale => $self->{locale}, |
568
|
17140
|
|
|
|
|
92447
|
nanosecond => 0, |
569
|
|
|
|
|
|
|
); |
570
|
|
|
|
|
|
|
|
571
|
17140
|
|
|
|
|
23071
|
PART: foreach my $part (@{$pattern}) { |
|
17140
|
|
|
|
|
37861
|
|
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
#my $before = $string; |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
# Pattern |
576
|
218044
|
100
|
|
|
|
2255484
|
if (ref $part eq 'ARRAY') { |
|
|
100
|
|
|
|
|
|
577
|
108273
|
|
|
|
|
119359
|
my ($regexp,$command,$index) = @{$part}; |
|
108273
|
|
|
|
|
333774
|
|
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
#print "TRY TO MATCH '$string' AGAINST '$regexp' WITH $command\n"; |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
# Match regexp part |
582
|
108273
|
100
|
|
2
|
|
14522134
|
return $datetime_error->($string) |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
24
|
|
583
|
|
|
|
|
|
|
unless ($string =~ s/^ \s* $regexp//ix); |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
# Get capture |
586
|
108269
|
|
|
|
|
1004444
|
my $capture = $1; |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
# Pattern is a list: get index instead of value |
589
|
108269
|
100
|
|
|
|
361742
|
if (ref $PARSER{$command.$index} eq '') { |
590
|
19900
|
|
|
|
|
36164
|
my $function = $PARSER{$command.$index}; |
591
|
19900
|
|
|
|
|
26565
|
my $count = 1; |
592
|
19900
|
|
|
|
|
23455
|
my $tmpcapture; |
593
|
19900
|
|
|
|
|
24693
|
foreach my $element (@{$self->{locale}->$function}) { |
|
19900
|
|
|
|
|
85993
|
|
594
|
133943
|
100
|
|
|
|
582620
|
if (lc($element) eq lc($capture)) { |
595
|
19901
|
100
|
|
|
|
53603
|
if (defined $tmpcapture) { |
596
|
1
|
|
|
|
|
5
|
$self->_local_carp("Expression '$capture' is ambigous for pattern '$command$index' "); |
597
|
1
|
|
|
|
|
4
|
next PART; |
598
|
|
|
|
|
|
|
} |
599
|
19900
|
|
|
|
|
26766
|
$tmpcapture = $count; |
600
|
|
|
|
|
|
|
} |
601
|
133942
|
|
|
|
|
176034
|
$count ++; |
602
|
|
|
|
|
|
|
} |
603
|
19899
|
|
|
|
|
35260
|
$capture = $tmpcapture; |
604
|
|
|
|
|
|
|
} |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
# Run patterns |
607
|
108268
|
100
|
100
|
|
|
1790480
|
if ($command eq 'G' ) { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
100
|
|
|
|
|
|
|
100
|
33
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
33
|
|
|
|
|
|
|
100
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
608
|
15
|
|
|
|
|
44
|
$datetime_info{era} = $capture; |
609
|
|
|
|
|
|
|
} elsif ($command eq 'y' && $index == 2) { |
610
|
2212
|
|
|
|
|
5287
|
$datetime{year} = $capture; |
611
|
2212
|
100
|
|
|
|
5641
|
if ($datetime{year} >= 70) { |
612
|
737
|
|
|
|
|
2272
|
$datetime{year} += 1900; |
613
|
|
|
|
|
|
|
} else { |
614
|
1475
|
|
|
|
|
4095
|
$datetime{year} += 2000; |
615
|
|
|
|
|
|
|
} |
616
|
|
|
|
|
|
|
} elsif ($command eq 'y' ) { |
617
|
12005
|
|
|
|
|
41646
|
$datetime{year} = $capture; |
618
|
|
|
|
|
|
|
} elsif ($command eq 'Q' || $command eq 'q') { |
619
|
30
|
|
|
|
|
95
|
$datetime_check{quarter} = $capture; |
620
|
|
|
|
|
|
|
} elsif ($command eq 'M' || $command eq 'L') { |
621
|
14254
|
|
|
|
|
47819
|
$datetime{month} = $capture; |
622
|
|
|
|
|
|
|
} elsif ($command eq 'w') { |
623
|
5
|
|
|
|
|
17
|
$datetime_check{week_number} = $capture; |
624
|
|
|
|
|
|
|
} elsif ($command eq 'W') { |
625
|
5
|
|
|
|
|
16
|
$datetime_check{week_of_month} = $capture; |
626
|
|
|
|
|
|
|
} elsif ($command eq 'd') { |
627
|
14216
|
|
|
|
|
50630
|
$datetime{day} = $capture; |
628
|
|
|
|
|
|
|
} elsif ($command eq 'D') { |
629
|
5
|
|
|
|
|
23
|
$datetime_check{day_of_year} = $capture; |
630
|
|
|
|
|
|
|
} elsif ($command eq 'e' && $index == 1) { |
631
|
5
|
|
|
|
|
18
|
my $fdow = $self->{locale}->first_day_of_week(); |
632
|
5
|
|
|
|
|
23
|
$capture -= (8 - $fdow); |
633
|
5
|
100
|
|
|
|
13
|
$capture += 7 if $capture < 1; |
634
|
5
|
|
|
|
|
19
|
$datetime_check{day_of_week} = $capture; |
635
|
|
|
|
|
|
|
} elsif ($command eq 'E' || $command eq 'c' || $command eq 'e') { |
636
|
3321
|
|
|
|
|
13344
|
$datetime_check{day_of_week} = $capture; |
637
|
|
|
|
|
|
|
} elsif ($command eq 'F') { |
638
|
5
|
|
|
|
|
16
|
$datetime_check{weekday_of_month} = $capture; |
639
|
|
|
|
|
|
|
} elsif ($command eq 'a' ) { |
640
|
8796
|
|
|
|
|
30759
|
$datetime_info{ampm} = $capture; |
641
|
|
|
|
|
|
|
} elsif ($command eq 'h') { # 1-12 |
642
|
8792
|
100
|
|
|
|
27495
|
$capture = 0 if $capture == 12; |
643
|
8792
|
|
|
|
|
30589
|
$datetime_info{hour12} = $capture; |
644
|
|
|
|
|
|
|
} elsif ($command eq 'K') { # 0-11 |
645
|
4
|
|
|
|
|
14
|
$datetime_info{hour12} = $capture; |
646
|
|
|
|
|
|
|
} elsif ($command eq 'H') { # 0-23 |
647
|
8144
|
|
|
|
|
28042
|
$datetime{hour} = $capture; |
648
|
|
|
|
|
|
|
} elsif ($command eq 'k') { # 1-24 |
649
|
8
|
|
|
|
|
26
|
$datetime_info{hour24} = $capture; |
650
|
|
|
|
|
|
|
} elsif ($command eq 'm') { |
651
|
16582
|
|
|
|
|
54522
|
$datetime{minute} = $capture; |
652
|
|
|
|
|
|
|
} elsif ($command eq 's') { |
653
|
12783
|
|
|
|
|
42337
|
$datetime{second} = $capture; |
654
|
|
|
|
|
|
|
} elsif ($command eq 'S' ) { |
655
|
12
|
|
|
|
|
61
|
$datetime{nanosecond} = int("0.$capture" * 1000000000); |
656
|
|
|
|
|
|
|
} elsif ($command eq 'Z') { |
657
|
240
|
100
|
|
|
|
551
|
if ($index >= 4) { |
658
|
120
|
|
|
|
|
246
|
$capture = $2; |
659
|
|
|
|
|
|
|
} |
660
|
240
|
|
|
|
|
884
|
$datetime{time_zone} = DateTime::TimeZone->new( name => $capture ); |
661
|
|
|
|
|
|
|
} elsif (($command eq 'z' || $command eq 'v' || $command eq 'V') && $index == 1) { |
662
|
3415
|
100
|
66
|
|
|
22156
|
if (! defined $ZONEMAP{$capture} |
663
|
|
|
|
|
|
|
|| $ZONEMAP{$capture} eq 'Ambiguous') { |
664
|
1
|
|
|
|
|
7
|
$self->_local_carp("Ambiguous timezone: $capture $command"); |
665
|
1
|
|
|
|
|
3
|
next; |
666
|
|
|
|
|
|
|
} |
667
|
3414
|
|
|
|
|
18132
|
$datetime{time_zone} = DateTime::TimeZone->new(name => $ZONEMAP{$capture}); |
668
|
|
|
|
|
|
|
} elsif ($command eq 'z' || $command eq 'v' || $command eq 'V') { |
669
|
3414
|
|
|
|
|
19171
|
$datetime{time_zone} = DateTime::TimeZone->new(name => $capture); |
670
|
|
|
|
|
|
|
} else { |
671
|
0
|
|
|
|
|
0
|
return $self->_local_croak("Could not get datetime for '$datetime_initial': Unknown pattern $command$index"); |
672
|
|
|
|
|
|
|
} |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
# String |
675
|
|
|
|
|
|
|
} elsif ($string !~ s/^ \s* $part//ix) { |
676
|
2
|
|
|
|
|
6
|
return $datetime_error->($string); |
677
|
|
|
|
|
|
|
} |
678
|
|
|
|
|
|
|
#print "BEFORE: '$before' AFTER: '$string' PATTERN: '$part'\n"; |
679
|
|
|
|
|
|
|
} |
680
|
|
|
|
|
|
|
|
681
|
17134
|
100
|
|
|
|
724470
|
return $datetime_error->($string) |
682
|
|
|
|
|
|
|
if $string ne ''; |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
# Handle 12 hour time notations |
685
|
17133
|
100
|
66
|
|
|
67712
|
if (defined $datetime_info{hour12} |
686
|
|
|
|
|
|
|
&& defined $datetime_info{ampm}) { |
687
|
8796
|
|
|
|
|
17241
|
$datetime{hour} = $datetime_info{hour12}; |
688
|
|
|
|
|
|
|
$datetime{hour} += 12 |
689
|
8796
|
100
|
66
|
|
|
42099
|
if $datetime_info{ampm} == 2 && $datetime{hour} < 12; |
690
|
|
|
|
|
|
|
} |
691
|
17133
|
100
|
|
|
|
41038
|
if (defined $datetime_info{hour24}) { |
692
|
8
|
|
|
|
|
18
|
$datetime{hour} = $datetime_info{hour24}; |
693
|
8
|
100
|
|
|
|
28
|
if ($datetime{hour} == 24) { |
694
|
3
|
|
|
|
|
66
|
$datetime{hour} = 0; |
695
|
|
|
|
|
|
|
} |
696
|
|
|
|
|
|
|
} |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
# Handle 24:00:00 time notations |
699
|
17133
|
100
|
|
|
|
44296
|
if ($datetime{hour} == 24) { |
700
|
3
|
100
|
66
|
|
|
25
|
if ($datetime{minute} == 0 |
|
|
|
66
|
|
|
|
|
701
|
|
|
|
|
|
|
&& $datetime{second} == 0 |
702
|
|
|
|
|
|
|
&& $datetime{nanosecond} == 0) { |
703
|
2
|
|
|
|
|
4
|
$datetime{hour} = 0; |
704
|
2
|
|
|
|
|
5
|
$datetime_info{dayadd} = 1; |
705
|
|
|
|
|
|
|
} else { |
706
|
1
|
|
|
|
|
8
|
return $self->_local_croak("Could not get datetime for $datetime_initial: Invalid 24-hour notation") |
707
|
|
|
|
|
|
|
} |
708
|
|
|
|
|
|
|
} |
709
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
# Handle era |
711
|
17132
|
50
|
66
|
|
|
48364
|
if (defined $datetime_info{era} |
|
|
|
33
|
|
|
|
|
712
|
|
|
|
|
|
|
&& $datetime_info{era} == 0 |
713
|
|
|
|
|
|
|
&& defined $datetime{year}) { |
714
|
0
|
|
|
|
|
0
|
$datetime{year} *= -1; |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
# Handle incomplete datetime information |
718
|
17132
|
100
|
66
|
|
|
109649
|
unless (defined $datetime{year} |
|
|
|
100
|
|
|
|
|
719
|
|
|
|
|
|
|
&& defined $datetime{month} |
720
|
|
|
|
|
|
|
&& defined $datetime{day}) { |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
# I want given/when in 5.8 |
723
|
2920
|
100
|
|
|
|
9083
|
if (ref $self->{incomplete} eq 'CODE') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
724
|
1
|
|
|
|
|
5
|
%datetime = &{$self->{incomplete}}($self,%datetime); |
|
1
|
|
|
|
|
5
|
|
725
|
|
|
|
|
|
|
} elsif ($self->{incomplete} eq '1') { |
726
|
2918
|
|
50
|
|
|
11006
|
$datetime{day} ||= 1; |
727
|
2918
|
|
100
|
|
|
9676
|
$datetime{month} ||= 1; |
728
|
2918
|
|
100
|
|
|
11348
|
$datetime{year} ||= 1; |
729
|
|
|
|
|
|
|
} elsif ($self->{incomplete} eq 'incomplete') { |
730
|
1
|
|
|
|
|
1098
|
require DateTime::Incomplete; |
731
|
1
|
|
|
|
|
63488
|
my $dt = eval { |
732
|
1
|
|
|
|
|
28
|
return DateTime::Incomplete->new(%datetime); |
733
|
|
|
|
|
|
|
}; |
734
|
1
|
50
|
33
|
|
|
77
|
return $self->_local_croak("Could not get datetime for $datetime_initial: $@") |
735
|
|
|
|
|
|
|
if $@ || ref $dt ne 'DateTime::Incomplete'; |
736
|
1
|
|
|
|
|
16
|
return $dt; |
737
|
|
|
|
|
|
|
} else { |
738
|
0
|
|
|
|
|
0
|
return $self->_local_croak("Could not get datetime for $datetime_initial: Invalid incomplete setting"); |
739
|
|
|
|
|
|
|
} |
740
|
|
|
|
|
|
|
} |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
# Build datetime |
743
|
17131
|
|
|
|
|
26686
|
my $dt = eval { |
744
|
17131
|
|
|
|
|
100847
|
return DateTime->new(%datetime); |
745
|
|
|
|
|
|
|
}; |
746
|
17131
|
100
|
66
|
|
|
6063299
|
return $self->_local_croak("Could not get datetime for $datetime_initial: $@") |
747
|
|
|
|
|
|
|
if $@ || ref $dt ne 'DateTime'; |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
# Postprocessing |
750
|
17128
|
100
|
|
|
|
42788
|
if ($datetime_info{dayadd}) { |
751
|
2
|
|
|
|
|
7
|
$dt->add( days => 1 ); |
752
|
|
|
|
|
|
|
} |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
# Perform checks |
755
|
17128
|
|
|
|
|
43169
|
foreach my $check ( keys %datetime_check ) { |
756
|
3376
|
100
|
|
|
|
12564
|
unless ($dt->$check == $datetime_check{$check}) { |
757
|
2
|
|
|
|
|
69
|
return $self->_local_croak("Datetime '$check' does not match ('$datetime_check{$check}' vs. '".$dt->$check."') for '$datetime_initial'"); |
758
|
|
|
|
|
|
|
} |
759
|
|
|
|
|
|
|
} |
760
|
|
|
|
|
|
|
|
761
|
17126
|
|
|
|
|
166679
|
return $dt; |
762
|
|
|
|
|
|
|
} |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=head3 format_datetime |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
my $string = $cldr->format_datetime($datetime); |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
Formats a C object using the set locale and pattern. (not the |
769
|
|
|
|
|
|
|
time_zone) |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
=cut |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
sub format_datetime { |
774
|
17077
|
|
|
17077
|
1
|
23124722
|
my ( $self, $dt ) = @_; |
775
|
|
|
|
|
|
|
|
776
|
17077
|
50
|
33
|
|
|
165356
|
$dt = DateTime->now |
|
|
|
33
|
|
|
|
|
777
|
|
|
|
|
|
|
unless defined $dt && ref $dt && $dt->isa('DateTime'); |
778
|
|
|
|
|
|
|
|
779
|
|
|
|
|
|
|
#see http://rt.cpan.org/Public/Bug/Display.html?id=49605 |
780
|
|
|
|
|
|
|
#my ( $self, $dt ) = validate_pos( @_, 1, { default => DateTime->now, type => OBJECT } ); |
781
|
17077
|
|
|
|
|
51430
|
$dt = $dt->clone; |
782
|
17077
|
|
|
|
|
231232
|
$dt->set_locale($self->{locale}); |
783
|
|
|
|
|
|
|
|
784
|
17077
|
|
|
|
|
430548
|
return $dt->format_cldr($self->{pattern}); |
785
|
|
|
|
|
|
|
} |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
=head3 errmsg |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
my $string = $cldr->errmsg(); |
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
Stores the last error message. Especially useful if the on_error behavior of the |
793
|
|
|
|
|
|
|
object is 'undef', so you can work out why things went wrong. |
794
|
|
|
|
|
|
|
|
795
|
|
|
|
|
|
|
=cut |
796
|
|
|
|
|
|
|
|
797
|
|
|
|
|
|
|
sub errmsg { |
798
|
1
|
|
|
1
|
1
|
911
|
return $_[0]->{errmsg}; |
799
|
|
|
|
|
|
|
} |
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
=head2 Exportable functions |
803
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
There are no methods exported by default, however the following are available: |
805
|
|
|
|
|
|
|
|
806
|
|
|
|
|
|
|
=head3 cldr_format |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
use DateTime::Format::CLDR qw(cldr_format); |
809
|
|
|
|
|
|
|
&cldr_format($pattern,$datetime); |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
=cut |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
sub cldr_format { |
814
|
1
|
|
|
1
|
1
|
514
|
my ($pattern, $datetime) = @_; |
815
|
|
|
|
|
|
|
|
816
|
1
|
|
|
|
|
6
|
return $datetime->format_cldr($pattern); |
817
|
|
|
|
|
|
|
} |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
=head3 cldr_parse |
820
|
|
|
|
|
|
|
|
821
|
|
|
|
|
|
|
use DateTime::Format::CLDR qw(cldr_parse); |
822
|
|
|
|
|
|
|
&cldr_parse($pattern,$string); |
823
|
|
|
|
|
|
|
OR |
824
|
|
|
|
|
|
|
&cldr_parse($pattern,$string,$locale); |
825
|
|
|
|
|
|
|
|
826
|
|
|
|
|
|
|
Default locale is 'en'. |
827
|
|
|
|
|
|
|
|
828
|
|
|
|
|
|
|
=cut |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
sub cldr_parse { |
831
|
1
|
|
|
1
|
1
|
837
|
my ($pattern, $string, $locale) = @_; |
832
|
|
|
|
|
|
|
|
833
|
1
|
|
50
|
|
|
6
|
$locale ||= 'en'; |
834
|
1
|
|
|
|
|
10
|
return DateTime::Format::CLDR->new( |
835
|
|
|
|
|
|
|
pattern => $pattern, |
836
|
|
|
|
|
|
|
locale => $locale, |
837
|
|
|
|
|
|
|
on_error=>'croak', |
838
|
|
|
|
|
|
|
)->parse_datetime($string); |
839
|
|
|
|
|
|
|
} |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
# --------------------------------------------------------------------------- |
843
|
|
|
|
|
|
|
# Private methods |
844
|
|
|
|
|
|
|
# --------------------------------------------------------------------------- |
845
|
|
|
|
|
|
|
|
846
|
|
|
|
|
|
|
# Parse the pattern and return a data sctructure that can be easily used |
847
|
|
|
|
|
|
|
# by parse_datetime |
848
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
sub _build_pattern { |
850
|
17140
|
|
|
17140
|
|
25725
|
my ($self) = @_; |
851
|
|
|
|
|
|
|
|
852
|
|
|
|
|
|
|
# Return cached pattern |
853
|
|
|
|
|
|
|
return $self->{_built_pattern} |
854
|
17140
|
100
|
|
|
|
68766
|
if defined $self->{_built_pattern}; |
855
|
|
|
|
|
|
|
|
856
|
97
|
|
|
|
|
261
|
$self->{_built_pattern} = []; |
857
|
|
|
|
|
|
|
|
858
|
|
|
|
|
|
|
# Try to parse pattern one element each time |
859
|
97
|
|
|
|
|
653
|
while ($self->{pattern} =~ m/\G |
860
|
|
|
|
|
|
|
(?: |
861
|
|
|
|
|
|
|
'((?:[^']|'')*)' # quote escaped bit of text |
862
|
|
|
|
|
|
|
# it needs to end with one |
863
|
|
|
|
|
|
|
# quote not followed by |
864
|
|
|
|
|
|
|
# another |
865
|
|
|
|
|
|
|
| |
866
|
|
|
|
|
|
|
(([a-zA-Z])\3*) # could be a pattern |
867
|
|
|
|
|
|
|
| |
868
|
|
|
|
|
|
|
(.) # anything else |
869
|
|
|
|
|
|
|
) |
870
|
|
|
|
|
|
|
/sxg) { |
871
|
818
|
|
|
|
|
1917
|
my ($string,$pattern,$rest) = ($1,$2,$4); |
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
|
874
|
|
|
|
|
|
|
# Found quoted string |
875
|
818
|
100
|
|
|
|
2314
|
if ($string) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
876
|
7
|
|
|
|
|
15
|
$string =~ s/\'\'/\'/g; |
877
|
7
|
|
|
|
|
11
|
push @{$self->{_built_pattern}}, _quotestring($string); |
|
7
|
|
|
|
|
21
|
|
878
|
|
|
|
|
|
|
|
879
|
|
|
|
|
|
|
# Found pattern |
880
|
|
|
|
|
|
|
} elsif ($pattern) { |
881
|
|
|
|
|
|
|
# Get length and command |
882
|
454
|
|
|
|
|
667
|
my $length = length $pattern; |
883
|
454
|
|
|
|
|
724
|
my $command = substr $pattern,0,1; |
884
|
454
|
|
|
|
|
505
|
my ($rule,$regexp,$index); |
885
|
|
|
|
|
|
|
|
886
|
|
|
|
|
|
|
# Inflate 'j' pattern depending on locale |
887
|
454
|
100
|
|
|
|
981
|
if ($command eq 'j') { |
888
|
1
|
50
|
|
|
|
5
|
$command = ($self->{locale}->prefers_24_hour_time()) ? 'H':'h'; |
889
|
|
|
|
|
|
|
} |
890
|
|
|
|
|
|
|
|
891
|
|
|
|
|
|
|
# Find most appropriate command |
892
|
454
|
|
|
|
|
1102
|
for (my $count = $length; $count > 0; $count --) { |
893
|
705
|
100
|
|
|
|
2225
|
if (defined $PARSER{$command.$count}) { |
894
|
454
|
|
|
|
|
771
|
$rule = $PARSER{$command.$count}; |
895
|
454
|
|
|
|
|
568
|
$index = $count; |
896
|
454
|
|
|
|
|
698
|
last; |
897
|
|
|
|
|
|
|
} |
898
|
|
|
|
|
|
|
} |
899
|
|
|
|
|
|
|
|
900
|
454
|
50
|
|
|
|
950
|
return $self->_local_croak("Broken pattern: $command $length") |
901
|
|
|
|
|
|
|
unless $rule; |
902
|
|
|
|
|
|
|
|
903
|
|
|
|
|
|
|
# Pattern definition is regular expression |
904
|
454
|
100
|
|
|
|
1031
|
if (ref $rule eq 'Regexp') { |
|
|
100
|
|
|
|
|
|
905
|
|
|
|
|
|
|
#$regexp = '0*'.$rule; # Match leading zeros |
906
|
384
|
|
|
|
|
517
|
$regexp = $rule; |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
# Pattern definition is array of possible values |
909
|
|
|
|
|
|
|
} elsif (ref $rule eq 'ARRAY') { |
910
|
|
|
|
|
|
|
|
911
|
22
|
|
|
|
|
60
|
$regexp = _quoteslist($rule); |
912
|
|
|
|
|
|
|
# Try to find matching element (long elements first) |
913
|
|
|
|
|
|
|
|
914
|
|
|
|
|
|
|
# Pattern definition is DateTime::Locale method (returning an array) |
915
|
|
|
|
|
|
|
} else { |
916
|
48
|
|
|
|
|
261
|
$regexp = _quoteslist($self->{locale}->$rule()); |
917
|
|
|
|
|
|
|
} |
918
|
|
|
|
|
|
|
|
919
|
454
|
|
|
|
|
986
|
push @{$self->{_built_pattern}},[$regexp,$command,$index]; |
|
454
|
|
|
|
|
2999
|
|
920
|
|
|
|
|
|
|
|
921
|
|
|
|
|
|
|
# Found unqoted string |
922
|
|
|
|
|
|
|
} elsif ($rest) { |
923
|
357
|
|
|
|
|
448
|
push @{$self->{_built_pattern}}, _quotestring($rest); |
|
357
|
|
|
|
|
931
|
|
924
|
|
|
|
|
|
|
} |
925
|
|
|
|
|
|
|
} |
926
|
|
|
|
|
|
|
|
927
|
97
|
|
|
|
|
215
|
return $self->{_built_pattern}; |
928
|
|
|
|
|
|
|
} |
929
|
|
|
|
|
|
|
|
930
|
|
|
|
|
|
|
# Turn array into regexp |
931
|
|
|
|
|
|
|
|
932
|
|
|
|
|
|
|
sub _quoteslist { |
933
|
70
|
|
|
70
|
|
244
|
my ($list) = @_; |
934
|
|
|
|
|
|
|
|
935
|
|
|
|
|
|
|
return |
936
|
|
|
|
|
|
|
'('. |
937
|
|
|
|
|
|
|
(join |
938
|
|
|
|
|
|
|
'|', |
939
|
7352
|
|
|
|
|
12136
|
map { _quotestring($_) } |
940
|
70
|
|
|
|
|
116
|
sort { length $b <=> length $a } @{$list} |
|
36986
|
|
|
|
|
42304
|
|
|
70
|
|
|
|
|
836
|
|
941
|
|
|
|
|
|
|
). |
942
|
|
|
|
|
|
|
')'; |
943
|
|
|
|
|
|
|
} |
944
|
|
|
|
|
|
|
|
945
|
|
|
|
|
|
|
# Quote regexp |
946
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
sub _quotestring { |
948
|
7716
|
|
|
7716
|
|
10978
|
my ($quote) = @_; |
949
|
|
|
|
|
|
|
|
950
|
7716
|
|
|
|
|
22070
|
$quote =~ s/([^[:alnum:][:space:]])/\\$1/g; |
951
|
7716
|
|
|
|
|
12152
|
$quote =~ s/\s+/\\s+/g; |
952
|
7716
|
|
|
|
|
16665
|
return $quote; |
953
|
|
|
|
|
|
|
} |
954
|
|
|
|
|
|
|
|
955
|
|
|
|
|
|
|
# Error |
956
|
|
|
|
|
|
|
|
957
|
|
|
|
|
|
|
sub _local_croak { |
958
|
13
|
|
|
13
|
|
36
|
my ($self,$message) = @_; |
959
|
|
|
|
|
|
|
|
960
|
13
|
|
|
|
|
22
|
$self->{errmsg} = $message; |
961
|
|
|
|
|
|
|
|
962
|
1
|
|
|
|
|
5
|
return &{$self->{on_error}}($self,$message,@_) |
963
|
13
|
100
|
|
|
|
41
|
if ref($self->{on_error}) eq 'CODE'; |
964
|
|
|
|
|
|
|
|
965
|
|
|
|
|
|
|
croak($message) |
966
|
12
|
100
|
|
|
|
288
|
if $self->{on_error} eq 'croak'; |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
return undef |
969
|
4
|
50
|
|
|
|
45
|
if ($self->{on_error} eq 'undef'); |
970
|
|
|
|
|
|
|
|
971
|
0
|
|
|
|
|
0
|
return; |
972
|
|
|
|
|
|
|
} |
973
|
|
|
|
|
|
|
|
974
|
|
|
|
|
|
|
# Warning |
975
|
|
|
|
|
|
|
|
976
|
|
|
|
|
|
|
sub _local_carp { |
977
|
2
|
|
|
2
|
|
4
|
my ($self,$message) = @_; |
978
|
|
|
|
|
|
|
|
979
|
2
|
|
|
|
|
5
|
$self->{errmsg} = $message; |
980
|
|
|
|
|
|
|
|
981
|
0
|
|
|
|
|
0
|
return &{$self->{on_error}}($self,$message,@_) |
982
|
2
|
50
|
|
|
|
7
|
if ref($self->{on_error}) eq 'CODE'; |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
carp($message) |
985
|
2
|
50
|
|
|
|
30
|
if $self->{on_error} eq 'croak'; |
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
return undef |
988
|
2
|
50
|
|
|
|
1463
|
if ($self->{on_error} eq 'undef'); |
989
|
|
|
|
|
|
|
|
990
|
2
|
|
|
|
|
5
|
return; |
991
|
|
|
|
|
|
|
} |
992
|
|
|
|
|
|
|
|
993
|
|
|
|
|
|
|
|
994
|
|
|
|
|
|
|
|
995
|
|
|
|
|
|
|
|
996
|
|
|
|
|
|
|
1; |
997
|
|
|
|
|
|
|
|
998
|
|
|
|
|
|
|
=head1 CLDR PATTERNS |
999
|
|
|
|
|
|
|
|
1000
|
|
|
|
|
|
|
=head2 Parsing |
1001
|
|
|
|
|
|
|
|
1002
|
|
|
|
|
|
|
Some patterns like day of week, quarter, ect. cannot be used to construct |
1003
|
|
|
|
|
|
|
a date. However these patterns can be parsed, and a warning will be |
1004
|
|
|
|
|
|
|
issued if they do not match the parsed date. |
1005
|
|
|
|
|
|
|
|
1006
|
|
|
|
|
|
|
Ambigous patterns (eg. narrow day of week formats for many locales) will |
1007
|
|
|
|
|
|
|
be parsed but ignored in datetime calculation. |
1008
|
|
|
|
|
|
|
|
1009
|
|
|
|
|
|
|
=head2 Supported CLDR Patterns |
1010
|
|
|
|
|
|
|
|
1011
|
|
|
|
|
|
|
See L. |
1012
|
|
|
|
|
|
|
|
1013
|
|
|
|
|
|
|
CLDR provides the following patterns: |
1014
|
|
|
|
|
|
|
|
1015
|
|
|
|
|
|
|
=over 4 |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
=item * G{1,3} |
1018
|
|
|
|
|
|
|
|
1019
|
|
|
|
|
|
|
The abbreviated era (BC, AD). |
1020
|
|
|
|
|
|
|
|
1021
|
|
|
|
|
|
|
=item * GGGG |
1022
|
|
|
|
|
|
|
|
1023
|
|
|
|
|
|
|
The wide era (Before Christ, Anno Domini). |
1024
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
=item * GGGGG |
1026
|
|
|
|
|
|
|
|
1027
|
|
|
|
|
|
|
The narrow era, if it exists (and it mostly doesn't). |
1028
|
|
|
|
|
|
|
|
1029
|
|
|
|
|
|
|
Not used to construct a date. |
1030
|
|
|
|
|
|
|
|
1031
|
|
|
|
|
|
|
=item * y and y{3,} |
1032
|
|
|
|
|
|
|
|
1033
|
|
|
|
|
|
|
The year, zero-prefixed as needed. |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
=item * yy |
1036
|
|
|
|
|
|
|
|
1037
|
|
|
|
|
|
|
This is a special case. It always produces a two-digit year, so "1976" |
1038
|
|
|
|
|
|
|
becomes "76". |
1039
|
|
|
|
|
|
|
|
1040
|
|
|
|
|
|
|
=item * Y{1,} |
1041
|
|
|
|
|
|
|
|
1042
|
|
|
|
|
|
|
The week of the year, from C<< $dt->week_year() >>. |
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
=item * u{1,} |
1045
|
|
|
|
|
|
|
|
1046
|
|
|
|
|
|
|
Same as "y" except that "uu" is not a special case. |
1047
|
|
|
|
|
|
|
|
1048
|
|
|
|
|
|
|
=item * Q{1,2} |
1049
|
|
|
|
|
|
|
|
1050
|
|
|
|
|
|
|
The quarter as a number (1..4). |
1051
|
|
|
|
|
|
|
|
1052
|
|
|
|
|
|
|
Not used to construct a date. |
1053
|
|
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
=item * QQQ |
1055
|
|
|
|
|
|
|
|
1056
|
|
|
|
|
|
|
The abbreviated format form for the quarter. |
1057
|
|
|
|
|
|
|
|
1058
|
|
|
|
|
|
|
Not used to construct a date. |
1059
|
|
|
|
|
|
|
|
1060
|
|
|
|
|
|
|
=item * QQQQ |
1061
|
|
|
|
|
|
|
|
1062
|
|
|
|
|
|
|
The wide format form for the quarter. |
1063
|
|
|
|
|
|
|
|
1064
|
|
|
|
|
|
|
Not used to construct a date. |
1065
|
|
|
|
|
|
|
|
1066
|
|
|
|
|
|
|
=item * q{1,2} |
1067
|
|
|
|
|
|
|
|
1068
|
|
|
|
|
|
|
The quarter as a number (1..4). |
1069
|
|
|
|
|
|
|
|
1070
|
|
|
|
|
|
|
Not used to construct a date. |
1071
|
|
|
|
|
|
|
|
1072
|
|
|
|
|
|
|
=item * qqq |
1073
|
|
|
|
|
|
|
|
1074
|
|
|
|
|
|
|
The abbreviated stand-alone form for the quarter. |
1075
|
|
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
Not used to construct a date. |
1077
|
|
|
|
|
|
|
|
1078
|
|
|
|
|
|
|
=item * qqqq |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
The wide stand-alone form for the quarter. |
1081
|
|
|
|
|
|
|
|
1082
|
|
|
|
|
|
|
Not used to construct a date. |
1083
|
|
|
|
|
|
|
|
1084
|
|
|
|
|
|
|
=item * M{1,2} |
1085
|
|
|
|
|
|
|
|
1086
|
|
|
|
|
|
|
The numerical month. |
1087
|
|
|
|
|
|
|
|
1088
|
|
|
|
|
|
|
=item * MMM |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
The abbreviated format form for the month. |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
=item * MMMM |
1093
|
|
|
|
|
|
|
|
1094
|
|
|
|
|
|
|
The wide format form for the month. |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
=item * MMMMM |
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
The narrow format form for the month. |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
=item * L{1,2} |
1101
|
|
|
|
|
|
|
|
1102
|
|
|
|
|
|
|
The numerical month. |
1103
|
|
|
|
|
|
|
|
1104
|
|
|
|
|
|
|
=item * LLL |
1105
|
|
|
|
|
|
|
|
1106
|
|
|
|
|
|
|
The abbreviated stand-alone form for the month. |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
=item * LLLL |
1109
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
The wide stand-alone form for the month. |
1111
|
|
|
|
|
|
|
|
1112
|
|
|
|
|
|
|
=item * LLLLL |
1113
|
|
|
|
|
|
|
|
1114
|
|
|
|
|
|
|
The narrow stand-alone form for the month. |
1115
|
|
|
|
|
|
|
|
1116
|
|
|
|
|
|
|
=item * w{1,2} |
1117
|
|
|
|
|
|
|
|
1118
|
|
|
|
|
|
|
The week of the year, from C<< $dt->week_number() >>. |
1119
|
|
|
|
|
|
|
|
1120
|
|
|
|
|
|
|
Not used to construct a date. |
1121
|
|
|
|
|
|
|
|
1122
|
|
|
|
|
|
|
=item * W |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
The week of the month, from C<< $dt->week_of_month() >>. |
1125
|
|
|
|
|
|
|
|
1126
|
|
|
|
|
|
|
Not used to construct a date. |
1127
|
|
|
|
|
|
|
|
1128
|
|
|
|
|
|
|
=item * d{1,2} |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
The numeric day of of the month. |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
=item * D{1,3} |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
The numeric day of of the year. |
1135
|
|
|
|
|
|
|
|
1136
|
|
|
|
|
|
|
Not used to construct a date. |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
=item * F |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
The day of the week in the month, from C<< $dt->weekday_of_month() >>. |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
Not used to construct a date. |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
=item * g{1,} |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
The modified Julian day, from C<< $dt->mjd() >>. |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
Not supported by DateTime::Format::CLDR |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
=item * E{1,3} |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
The abbreviated format form for the day of the week. |
1153
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
Not used to construct a date. |
1155
|
|
|
|
|
|
|
|
1156
|
|
|
|
|
|
|
=item * EEEE |
1157
|
|
|
|
|
|
|
|
1158
|
|
|
|
|
|
|
The wide format form for the day of the week. |
1159
|
|
|
|
|
|
|
|
1160
|
|
|
|
|
|
|
Not used to construct a date. |
1161
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
=item * EEEEE |
1163
|
|
|
|
|
|
|
|
1164
|
|
|
|
|
|
|
The narrow format form for the day of the week. |
1165
|
|
|
|
|
|
|
|
1166
|
|
|
|
|
|
|
Not used to construct a date. |
1167
|
|
|
|
|
|
|
|
1168
|
|
|
|
|
|
|
=item * e{1,2} |
1169
|
|
|
|
|
|
|
|
1170
|
|
|
|
|
|
|
The I day of the week, from 1 to 7. This number depends on what |
1171
|
|
|
|
|
|
|
day is considered the first day of the week, which varies by |
1172
|
|
|
|
|
|
|
locale. For example, in the US, Sunday is the first day of the week, |
1173
|
|
|
|
|
|
|
so this returns 2 for Monday. |
1174
|
|
|
|
|
|
|
|
1175
|
|
|
|
|
|
|
Not used to construct a date. |
1176
|
|
|
|
|
|
|
|
1177
|
|
|
|
|
|
|
=item * eee |
1178
|
|
|
|
|
|
|
|
1179
|
|
|
|
|
|
|
The abbreviated format form for the day of the week. |
1180
|
|
|
|
|
|
|
|
1181
|
|
|
|
|
|
|
Not used to construct a date. |
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
=item * eeee |
1184
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
The wide format form for the day of the week. |
1186
|
|
|
|
|
|
|
|
1187
|
|
|
|
|
|
|
Not used to construct a date. |
1188
|
|
|
|
|
|
|
|
1189
|
|
|
|
|
|
|
=item * eeeee |
1190
|
|
|
|
|
|
|
|
1191
|
|
|
|
|
|
|
The narrow format form for the day of the week. |
1192
|
|
|
|
|
|
|
|
1193
|
|
|
|
|
|
|
Not used to construct a date. |
1194
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
=item * c |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
The numeric day of the week (not localized). |
1198
|
|
|
|
|
|
|
|
1199
|
|
|
|
|
|
|
Not used to construct a date. |
1200
|
|
|
|
|
|
|
|
1201
|
|
|
|
|
|
|
=item * ccc |
1202
|
|
|
|
|
|
|
|
1203
|
|
|
|
|
|
|
The abbreviated stand-alone form for the day of the week. |
1204
|
|
|
|
|
|
|
|
1205
|
|
|
|
|
|
|
Not used to construct a date. |
1206
|
|
|
|
|
|
|
|
1207
|
|
|
|
|
|
|
=item * cccc |
1208
|
|
|
|
|
|
|
|
1209
|
|
|
|
|
|
|
The wide stand-alone form for the day of the week. |
1210
|
|
|
|
|
|
|
|
1211
|
|
|
|
|
|
|
Not used to construct a date. |
1212
|
|
|
|
|
|
|
|
1213
|
|
|
|
|
|
|
=item * ccccc |
1214
|
|
|
|
|
|
|
|
1215
|
|
|
|
|
|
|
The narrow format form for the day of the week. |
1216
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
Not used to construct a date. |
1218
|
|
|
|
|
|
|
|
1219
|
|
|
|
|
|
|
=item * a |
1220
|
|
|
|
|
|
|
|
1221
|
|
|
|
|
|
|
The localized form of AM or PM for the time. |
1222
|
|
|
|
|
|
|
|
1223
|
|
|
|
|
|
|
=item * h{1,2} |
1224
|
|
|
|
|
|
|
|
1225
|
|
|
|
|
|
|
The hour from 1-12. |
1226
|
|
|
|
|
|
|
|
1227
|
|
|
|
|
|
|
=item * H{1,2} |
1228
|
|
|
|
|
|
|
|
1229
|
|
|
|
|
|
|
The hour from 0-23. |
1230
|
|
|
|
|
|
|
|
1231
|
|
|
|
|
|
|
=item * K{1,2} |
1232
|
|
|
|
|
|
|
|
1233
|
|
|
|
|
|
|
The hour from 0-11. |
1234
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
=item * k{1,2} |
1236
|
|
|
|
|
|
|
|
1237
|
|
|
|
|
|
|
The hour from 1-24. Note that hour 24 is equivalent to midnight on the date |
1238
|
|
|
|
|
|
|
being parsed, not midnight of the next day. |
1239
|
|
|
|
|
|
|
|
1240
|
|
|
|
|
|
|
=item * j{1,2} |
1241
|
|
|
|
|
|
|
|
1242
|
|
|
|
|
|
|
The hour, in 12 or 24 hour form, based on the preferred form for the |
1243
|
|
|
|
|
|
|
locale. In other words, this is equivalent to either "h{1,2}" or |
1244
|
|
|
|
|
|
|
"H{1,2}". |
1245
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
=item * m{1,2} |
1247
|
|
|
|
|
|
|
|
1248
|
|
|
|
|
|
|
The minute. |
1249
|
|
|
|
|
|
|
|
1250
|
|
|
|
|
|
|
=item * s{1,2} |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
The second. |
1253
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
=item * S{1,} |
1255
|
|
|
|
|
|
|
|
1256
|
|
|
|
|
|
|
The fractional portion of the seconds, rounded based on the length of the |
1257
|
|
|
|
|
|
|
specifier. This returned without a leading decimal point, but may have |
1258
|
|
|
|
|
|
|
leading or trailing zeroes. |
1259
|
|
|
|
|
|
|
|
1260
|
|
|
|
|
|
|
=item * A{1,} |
1261
|
|
|
|
|
|
|
|
1262
|
|
|
|
|
|
|
The millisecond of the day, based on the current time. In other words, if it |
1263
|
|
|
|
|
|
|
is 12:00:00.00, this returns 43200000. |
1264
|
|
|
|
|
|
|
|
1265
|
|
|
|
|
|
|
Not supported by DateTime::Format::CLDR |
1266
|
|
|
|
|
|
|
|
1267
|
|
|
|
|
|
|
=item * z{1,3} |
1268
|
|
|
|
|
|
|
|
1269
|
|
|
|
|
|
|
The time zone short name. |
1270
|
|
|
|
|
|
|
|
1271
|
|
|
|
|
|
|
=item * zzzz |
1272
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
The time zone long name. |
1274
|
|
|
|
|
|
|
|
1275
|
|
|
|
|
|
|
=item * Z{1,3} |
1276
|
|
|
|
|
|
|
|
1277
|
|
|
|
|
|
|
The time zone offset. |
1278
|
|
|
|
|
|
|
|
1279
|
|
|
|
|
|
|
=item * ZZZZ |
1280
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
The time zone short name and the offset as one string, so something like |
1282
|
|
|
|
|
|
|
"CDT-0500". |
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
=item * v{1,3} |
1285
|
|
|
|
|
|
|
|
1286
|
|
|
|
|
|
|
The time zone short name. |
1287
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
=item * vvvv |
1289
|
|
|
|
|
|
|
|
1290
|
|
|
|
|
|
|
The time zone long name. |
1291
|
|
|
|
|
|
|
|
1292
|
|
|
|
|
|
|
=item * V{1,3} |
1293
|
|
|
|
|
|
|
|
1294
|
|
|
|
|
|
|
The time zone short name. |
1295
|
|
|
|
|
|
|
|
1296
|
|
|
|
|
|
|
=item * VVVV |
1297
|
|
|
|
|
|
|
|
1298
|
|
|
|
|
|
|
The time zone long name. |
1299
|
|
|
|
|
|
|
|
1300
|
|
|
|
|
|
|
=back |
1301
|
|
|
|
|
|
|
|
1302
|
|
|
|
|
|
|
=head1 CAVEATS |
1303
|
|
|
|
|
|
|
|
1304
|
|
|
|
|
|
|
Patterns without separators (like 'dMy' or 'yMd') are ambigous for some |
1305
|
|
|
|
|
|
|
dates and might fail. |
1306
|
|
|
|
|
|
|
|
1307
|
|
|
|
|
|
|
Quote from the Author of C which also applies to |
1308
|
|
|
|
|
|
|
this module: |
1309
|
|
|
|
|
|
|
|
1310
|
|
|
|
|
|
|
"If your module uses this module to parse a known format: stop it. This module |
1311
|
|
|
|
|
|
|
is clunky and slow because it can parse almost anything. Parsing a known |
1312
|
|
|
|
|
|
|
format is not so difficult, is it? You'll make your module faster if you do. |
1313
|
|
|
|
|
|
|
And you're not left at the whim of my potentially broken code." |
1314
|
|
|
|
|
|
|
|
1315
|
|
|
|
|
|
|
=head1 SUPPORT |
1316
|
|
|
|
|
|
|
|
1317
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
1318
|
|
|
|
|
|
|
C, or through the web interface at |
1319
|
|
|
|
|
|
|
L. |
1320
|
|
|
|
|
|
|
I will be notified and then you'll automatically be notified of the progress |
1321
|
|
|
|
|
|
|
on your report as I make changes. |
1322
|
|
|
|
|
|
|
|
1323
|
|
|
|
|
|
|
=head1 SEE ALSO |
1324
|
|
|
|
|
|
|
|
1325
|
|
|
|
|
|
|
datetime@perl.org mailing list |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
L |
1328
|
|
|
|
|
|
|
|
1329
|
|
|
|
|
|
|
L, L, L |
1330
|
|
|
|
|
|
|
and L |
1331
|
|
|
|
|
|
|
|
1332
|
|
|
|
|
|
|
=head1 AUTHOR |
1333
|
|
|
|
|
|
|
|
1334
|
|
|
|
|
|
|
Maroš Kollár |
1335
|
|
|
|
|
|
|
CPAN ID: MAROS |
1336
|
|
|
|
|
|
|
maros [at] k-1.com |
1337
|
|
|
|
|
|
|
|
1338
|
|
|
|
|
|
|
http://www.k-1.com |
1339
|
|
|
|
|
|
|
|
1340
|
|
|
|
|
|
|
=head1 COPYRIGHT |
1341
|
|
|
|
|
|
|
|
1342
|
|
|
|
|
|
|
DateTime::Format::CLDR is Copyright (c) 2008-2012 Maroš Kollár |
1343
|
|
|
|
|
|
|
- L |
1344
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
=head1 LICENCE |
1346
|
|
|
|
|
|
|
|
1347
|
|
|
|
|
|
|
This library is free software, you can redistribute it and/or modify |
1348
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
1349
|
|
|
|
|
|
|
|
1350
|
|
|
|
|
|
|
=cut |