line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Locale::Base; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1369
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
5
|
2
|
|
|
2
|
|
10
|
use namespace::autoclean; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.39'; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
197
|
use Carp qw( carp ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
139
|
|
10
|
2
|
|
|
2
|
|
15
|
use DateTime::Locale; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
77
|
|
11
|
2
|
|
|
2
|
|
13
|
use List::Util 1.45 (); |
|
2
|
|
|
|
|
36
|
|
|
2
|
|
|
|
|
76
|
|
12
|
2
|
|
|
2
|
|
11
|
use Params::ValidationCompiler 0.13 qw( validation_for ); |
|
2
|
|
|
|
|
30
|
|
|
2
|
|
|
|
|
84
|
|
13
|
2
|
|
|
2
|
|
10
|
use Specio::Declare; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
BEGIN { |
16
|
2
|
|
|
2
|
|
9
|
foreach my $field ( |
17
|
|
|
|
|
|
|
qw( id en_complete_name native_complete_name |
18
|
|
|
|
|
|
|
en_language en_script en_territory en_variant |
19
|
|
|
|
|
|
|
native_language native_script native_territory native_variant |
20
|
|
|
|
|
|
|
) |
21
|
|
|
|
|
|
|
) { |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# remove leading 'en_' for method name |
24
|
22
|
|
|
|
|
64
|
( my $meth_name = $field ) =~ s/^en_//; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# also remove 'complete_' |
27
|
22
|
|
|
|
|
37
|
$meth_name =~ s/complete_//; |
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
2
|
|
501
|
no strict 'refs'; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
157
|
|
30
|
22
|
|
|
6
|
|
61
|
*{$meth_name} = sub { $_[0]->{$field} }; |
|
22
|
|
|
|
|
1457
|
|
|
6
|
|
|
|
|
6452
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
35
|
7
|
|
|
7
|
0
|
15
|
my $class = shift; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# By making the default format lengths part of the object's hash |
38
|
|
|
|
|
|
|
# key, it allows them to be settable. |
39
|
7
|
|
|
|
|
50
|
return bless { |
40
|
|
|
|
|
|
|
@_, |
41
|
|
|
|
|
|
|
default_date_format_length => 'long', |
42
|
|
|
|
|
|
|
default_time_format_length => 'long', |
43
|
|
|
|
|
|
|
}, $class; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
0
|
1
|
|
sub language_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[0] } |
47
|
0
|
|
|
0
|
1
|
|
sub script_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[1] } |
48
|
0
|
|
|
0
|
1
|
|
sub territory_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[2] } |
49
|
0
|
|
|
0
|
1
|
|
sub variant_id { ( DateTime::Locale::_parse_id( $_[0]->id ) )[3] } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my @FormatLengths = qw( short medium long full ); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub date_format_default { |
54
|
0
|
|
|
0
|
1
|
|
my $meth = 'date_format_' . $_[0]->default_date_format_length(); |
55
|
0
|
|
|
|
|
|
$_[0]->$meth(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub date_formats { |
59
|
|
|
|
|
|
|
return { |
60
|
|
|
|
|
|
|
map { |
61
|
0
|
|
|
0
|
1
|
|
my $meth = 'date_format_' . $_; |
|
0
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
$_ => $_[0]->$meth() |
63
|
|
|
|
|
|
|
} @FormatLengths |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub time_format_default { |
68
|
0
|
|
|
0
|
1
|
|
my $meth = 'time_format_' . $_[0]->default_time_format_length(); |
69
|
0
|
|
|
|
|
|
$_[0]->$meth(); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub time_formats { |
73
|
|
|
|
|
|
|
return { |
74
|
|
|
|
|
|
|
map { |
75
|
0
|
|
|
0
|
1
|
|
my $meth = 'time_format_' . $_; |
|
0
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$_ => $_[0]->$meth() |
77
|
|
|
|
|
|
|
} @FormatLengths |
78
|
|
|
|
|
|
|
}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub format_for { |
82
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
83
|
0
|
|
|
|
|
|
my $for = shift; |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my $meth = '_format_for_' . $for; |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
return unless $self->can($meth); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return $self->$meth(); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub available_formats { |
93
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# The various parens seem to be necessary to force uniq() to see |
96
|
|
|
|
|
|
|
# the caller's list context. Go figure. |
97
|
|
|
|
|
|
|
my @uniq |
98
|
0
|
0
|
|
|
|
|
= List::Util::uniq( map { keys %{ $_->_available_formats() || {} } } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
_self_and_super_path( ref $self ) ); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Doing the sort in the same expression doesn't work under 5.6.x. |
102
|
0
|
|
|
|
|
|
return sort @uniq; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Copied wholesale from Class::ISA, because said module warns as deprecated |
106
|
|
|
|
|
|
|
# with perl 5.11.0+, which is kind of annoying. |
107
|
|
|
|
|
|
|
sub _self_and_super_path { |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# Assumption: searching is depth-first. |
110
|
|
|
|
|
|
|
# Assumption: '' (empty string) can't be a class package name. |
111
|
|
|
|
|
|
|
# Note: 'UNIVERSAL' is not given any special treatment. |
112
|
0
|
0
|
|
0
|
|
|
return () unless @_; |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
my @out = (); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my @in_stack = ( $_[0] ); |
117
|
0
|
|
|
|
|
|
my %seen = ( $_[0] => 1 ); |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $current; |
120
|
0
|
|
|
|
|
|
while (@in_stack) { |
121
|
0
|
0
|
0
|
|
|
|
next unless defined( $current = shift @in_stack ) && length($current); |
122
|
0
|
|
|
|
|
|
push @out, $current; |
123
|
2
|
|
|
2
|
|
30
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
838
|
|
124
|
|
|
|
|
|
|
unshift @in_stack, map { |
125
|
0
|
|
|
|
|
|
my $c = $_; # copy, to avoid being destructive |
126
|
0
|
0
|
|
|
|
|
substr( $c, 0, 2 ) = "main::" if substr( $c, 0, 2 ) eq '::'; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Canonize the :: -> main::, ::foo -> main::foo thing. |
129
|
|
|
|
|
|
|
# Should I ever canonize the Foo'Bar = Foo::Bar thing? |
130
|
0
|
0
|
|
|
|
|
$seen{$c}++ ? () : $c; |
131
|
0
|
|
|
|
|
|
} @{"$current\::ISA"}; |
|
0
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# I.e., if this class has any parents (at least, ones I've never seen |
134
|
|
|
|
|
|
|
# before), push them, in order, onto the stack of classes I need to |
135
|
|
|
|
|
|
|
# explore. |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
return @out; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Just needed for the above method. |
142
|
|
|
|
0
|
|
|
sub _available_formats { } |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
0
|
1
|
|
sub default_date_format_length { $_[0]->{default_date_format_length} } |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
my $length = enum( values => [qw( full long medium short )] ); |
147
|
|
|
|
|
|
|
my $validator = validation_for( |
148
|
|
|
|
|
|
|
name => '_check_length_parameter', |
149
|
|
|
|
|
|
|
name_is_optional => 1, |
150
|
|
|
|
|
|
|
params => [ { type => $length } ], |
151
|
|
|
|
|
|
|
); |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub set_default_date_format_length { |
154
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
155
|
0
|
|
|
|
|
|
my ($l) = $validator->(@_); |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
$self->{default_date_format_length} = lc $l; |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
0
|
1
|
|
sub default_time_format_length { $_[0]->{default_time_format_length} } |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub set_default_time_format_length { |
163
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
164
|
0
|
|
|
|
|
|
my ($l) = $validator->(@_); |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
$self->{default_time_format_length} = lc $l; |
167
|
|
|
|
|
|
|
} |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
for my $length (qw( full long medium short )) { |
170
|
|
|
|
|
|
|
my $key = 'datetime_format_' . $length; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
my $sub = sub { |
173
|
0
|
|
|
0
|
|
|
my $self = shift; |
174
|
|
|
|
|
|
|
|
175
|
0
|
0
|
|
|
|
|
return $self->{$key} if exists $self->{$key}; |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
my $date_meth = 'date_format_' . $length; |
178
|
0
|
|
|
|
|
|
my $time_meth = 'time_format_' . $length; |
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
return $self->{$key} |
181
|
|
|
|
|
|
|
= $self->_make_datetime_format( $date_meth, $time_meth ); |
182
|
|
|
|
|
|
|
}; |
183
|
|
|
|
|
|
|
|
184
|
2
|
|
|
2
|
|
39
|
no strict 'refs'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
3267
|
|
185
|
|
|
|
|
|
|
*{$key} = $sub; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub datetime_format_default { |
189
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $date_meth = 'date_format_' . $self->default_date_format_length(); |
192
|
0
|
|
|
|
|
|
my $time_meth = 'time_format_' . $self->default_time_format_length(); |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
|
return $self->_make_datetime_format( $date_meth, $time_meth ); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub _make_datetime_format { |
198
|
0
|
|
|
0
|
|
|
my $self = shift; |
199
|
0
|
|
|
|
|
|
my $date_meth = shift; |
200
|
0
|
|
|
|
|
|
my $time_meth = shift; |
201
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
my $dt_format = $self->datetime_format(); |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
my $time = $self->$time_meth(); |
205
|
0
|
|
|
|
|
|
my $date = $self->$date_meth(); |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
$dt_format =~ s/\{0\}/$time/g; |
208
|
0
|
|
|
|
|
|
$dt_format =~ s/\{1\}/$date/g; |
209
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
return $dt_format; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub prefers_24_hour_time { |
214
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
return $self->{prefers_24_hour_time} |
217
|
0
|
0
|
|
|
|
|
if exists $self->{prefers_24_hour_time}; |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
$self->{prefers_24_hour_time} |
220
|
0
|
0
|
|
|
|
|
= $self->time_format_short() =~ /h|K/ ? 0 : 1; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
# Backwards compat for DateTime.pm version <= 0.42 |
224
|
|
|
|
|
|
|
{ |
225
|
|
|
|
|
|
|
my %subs = ( |
226
|
|
|
|
|
|
|
month_name => sub { $_[0]->month_format_wide()->[ $_[1]->month_0 ] }, |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
month_abbreviation => sub { |
229
|
|
|
|
|
|
|
$_[0]->month_format_abbreviated()->[ $_[1]->month_0 ]; |
230
|
|
|
|
|
|
|
}, |
231
|
|
|
|
|
|
|
month_narrow => |
232
|
|
|
|
|
|
|
sub { $_[0]->month_format_narrow()->[ $_[1]->month_0 ]; }, |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
month_names => sub { $_[0]->month_format_wide() }, |
235
|
|
|
|
|
|
|
month_abbreviations => sub { $_[0]->month_format_abbreviated() }, |
236
|
|
|
|
|
|
|
month_narrows => sub { $_[0]->month_format_narrow() }, |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
day_name => |
239
|
|
|
|
|
|
|
sub { $_[0]->day_format_wide()->[ $_[1]->day_of_week_0 ] }, |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
day_abbreviation => sub { |
242
|
|
|
|
|
|
|
$_[0]->day_format_abbreviated()->[ $_[1]->day_of_week_0 ]; |
243
|
|
|
|
|
|
|
}, |
244
|
|
|
|
|
|
|
day_narrow => |
245
|
|
|
|
|
|
|
sub { $_[0]->day_format_narrow()->[ $_[1]->day_of_week_0 ]; }, |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
day_names => sub { $_[0]->day_format_wide() }, |
248
|
|
|
|
|
|
|
day_abbreviations => sub { $_[0]->day_format_abbreviated() }, |
249
|
|
|
|
|
|
|
day_narrows => sub { $_[0]->day_format_narrow() }, |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
quarter_name => |
252
|
|
|
|
|
|
|
sub { $_[0]->quarter_format_wide()->[ $_[1]->quarter - 1 ] }, |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
quarter_abbreviation => sub { |
255
|
|
|
|
|
|
|
$_[0]->quarter_format_abbreviated()->[ $_[1]->quarter - 1 ]; |
256
|
|
|
|
|
|
|
}, |
257
|
|
|
|
|
|
|
quarter_narrow => |
258
|
|
|
|
|
|
|
sub { $_[0]->quarter_format_narrow()->[ $_[1]->quarter - 1 ] }, |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
quarter_names => sub { $_[0]->quarter_format_wide() }, |
261
|
|
|
|
|
|
|
quarter_abbreviations => sub { $_[0]->quarter_format_abbreviated() }, |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
am_pm => |
264
|
|
|
|
|
|
|
sub { $_[0]->am_pm_abbreviated()->[ $_[1]->hour < 12 ? 0 : 1 ] }, |
265
|
|
|
|
|
|
|
am_pms => sub { $_[0]->am_pm_abbreviated() }, |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
era_name => sub { $_[0]->era_wide()->[ $_[1]->ce_year < 0 ? 0 : 1 ] }, |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
era_abbreviation => sub { |
270
|
|
|
|
|
|
|
$_[0]->era_abbreviated()->[ $_[1]->ce_year < 0 ? 0 : 1 ]; |
271
|
|
|
|
|
|
|
}, |
272
|
|
|
|
|
|
|
era_narrow => |
273
|
|
|
|
|
|
|
sub { $_[0]->era_narrow()->[ $_[1]->ce_year < 0 ? 0 : 1 ] }, |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
era_names => sub { $_[0]->era_wide() }, |
276
|
|
|
|
|
|
|
era_abbreviations => sub { $_[0]->era_abbreviated() }, |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
# ancient backwards compat |
279
|
|
|
|
|
|
|
era => sub { $_[0]->era_abbreviation }, |
280
|
|
|
|
|
|
|
eras => sub { $_[0]->era_abbreviations }, |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
date_before_time => sub { |
283
|
|
|
|
|
|
|
my $self = shift; |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
my $dt_format = $self->datetime_format(); |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
return $dt_format =~ /\{1\}.*\{0\}/ ? 1 : 0; |
288
|
|
|
|
|
|
|
}, |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
date_parts_order => sub { |
291
|
|
|
|
|
|
|
my $self = shift; |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
my $short = $self->date_format_short(); |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
$short =~ tr{dmyDMY}{}cd; |
296
|
|
|
|
|
|
|
$short =~ tr{dmyDMY}{dmydmy}s; |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
return $short; |
299
|
|
|
|
|
|
|
}, |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
full_date_format => sub { |
302
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->date_format_full() ); |
303
|
|
|
|
|
|
|
}, |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
long_date_format => sub { |
306
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->date_format_long() ); |
307
|
|
|
|
|
|
|
}, |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
medium_date_format => sub { |
310
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->date_format_medium() ); |
311
|
|
|
|
|
|
|
}, |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
short_date_format => sub { |
314
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->date_format_short() ); |
315
|
|
|
|
|
|
|
}, |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
default_date_format => sub { |
318
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->date_format_default() ); |
319
|
|
|
|
|
|
|
}, |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
full_time_format => sub { |
322
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->time_format_full() ); |
323
|
|
|
|
|
|
|
}, |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
long_time_format => sub { |
326
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->time_format_long() ); |
327
|
|
|
|
|
|
|
}, |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
medium_time_format => sub { |
330
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->time_format_medium() ); |
331
|
|
|
|
|
|
|
}, |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
short_time_format => sub { |
334
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->time_format_short() ); |
335
|
|
|
|
|
|
|
}, |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
default_time_format => sub { |
338
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->time_format_default() ); |
339
|
|
|
|
|
|
|
}, |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
full_datetime_format => sub { |
342
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->datetime_format_full() ); |
343
|
|
|
|
|
|
|
}, |
344
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
long_datetime_format => sub { |
346
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->datetime_format_long() ); |
347
|
|
|
|
|
|
|
}, |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
medium_datetime_format => sub { |
350
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->datetime_format_medium() ); |
351
|
|
|
|
|
|
|
}, |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
short_datetime_format => sub { |
354
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->datetime_format_short() ); |
355
|
|
|
|
|
|
|
}, |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
default_datetime_format => sub { |
358
|
|
|
|
|
|
|
$_[0]->_convert_to_strftime( $_[0]->datetime_format_default() ); |
359
|
|
|
|
|
|
|
}, |
360
|
|
|
|
|
|
|
); |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
for my $name ( keys %subs ) { |
363
|
|
|
|
|
|
|
my $real_sub = $subs{$name}; |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
my $sub = sub { |
366
|
0
|
|
|
0
|
|
|
carp |
367
|
|
|
|
|
|
|
"The $name method in DateTime::Locale::Base has been deprecated. Please see the DateTime::Locale distribution's Changes file for details"; |
368
|
0
|
|
|
|
|
|
return shift->$real_sub(@_); |
369
|
|
|
|
|
|
|
}; |
370
|
|
|
|
|
|
|
|
371
|
2
|
|
|
2
|
|
22
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1788
|
|
372
|
|
|
|
|
|
|
*{$name} = $sub; |
373
|
|
|
|
|
|
|
} |
374
|
|
|
|
|
|
|
} |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
# Older versions of DateTime.pm will not pass in the $cldr_ok flag, so |
377
|
|
|
|
|
|
|
# we will give them the converted-to-strftime pattern (bugs and all). |
378
|
|
|
|
|
|
|
sub _convert_to_strftime { |
379
|
0
|
|
|
0
|
|
|
my $self = shift; |
380
|
0
|
|
|
|
|
|
my $pattern = shift; |
381
|
0
|
|
|
|
|
|
my $cldr_ok = shift; |
382
|
|
|
|
|
|
|
|
383
|
0
|
0
|
|
|
|
|
return $pattern if $cldr_ok; |
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
return $self->{_converted_patterns}{$pattern} |
386
|
0
|
0
|
|
|
|
|
if exists $self->{_converted_patterns}{$pattern}; |
387
|
|
|
|
|
|
|
|
388
|
0
|
|
|
|
|
|
return $self->{_converted_patterns}{$pattern} |
389
|
|
|
|
|
|
|
= $self->_cldr_to_strftime($pattern); |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
{ |
393
|
|
|
|
|
|
|
my @JavaPatterns = ( |
394
|
|
|
|
|
|
|
qr/G/ => '{era}', |
395
|
|
|
|
|
|
|
qr/yyyy/ => '{ce_year}', |
396
|
|
|
|
|
|
|
qr/y/ => 'y', |
397
|
|
|
|
|
|
|
qr/u/ => 'Y', |
398
|
|
|
|
|
|
|
qr/MMMM/ => 'B', |
399
|
|
|
|
|
|
|
qr/MMM/ => 'b', |
400
|
|
|
|
|
|
|
qr/MM/ => 'm', |
401
|
|
|
|
|
|
|
qr/M/ => '{month}', |
402
|
|
|
|
|
|
|
qr/dd/ => 'd', |
403
|
|
|
|
|
|
|
qr/d/ => '{day}', |
404
|
|
|
|
|
|
|
qr/hh/ => 'l', |
405
|
|
|
|
|
|
|
qr/h/ => '{hour_12}', |
406
|
|
|
|
|
|
|
qr/HH/ => 'H', |
407
|
|
|
|
|
|
|
qr/H/ => '{hour}', |
408
|
|
|
|
|
|
|
qr/mm/ => 'M', |
409
|
|
|
|
|
|
|
qr/m/ => '{minute}', |
410
|
|
|
|
|
|
|
qr/ss/ => 'S', |
411
|
|
|
|
|
|
|
qr/s/ => '{second}', |
412
|
|
|
|
|
|
|
qr/S/ => 'N', |
413
|
|
|
|
|
|
|
qr/EEEE/ => 'A', |
414
|
|
|
|
|
|
|
qr/E/ => 'a', |
415
|
|
|
|
|
|
|
qr/D/ => 'j', |
416
|
|
|
|
|
|
|
qr/F/ => '{weekday_of_month}', |
417
|
|
|
|
|
|
|
qr/w/ => 'V', |
418
|
|
|
|
|
|
|
qr/W/ => '{week_month}', |
419
|
|
|
|
|
|
|
qr/a/ => 'p', |
420
|
|
|
|
|
|
|
qr/k/ => '{hour_1}', |
421
|
|
|
|
|
|
|
qr/K/ => '{hour_12_0}', |
422
|
|
|
|
|
|
|
qr/z/ => '{time_zone_long_name}', |
423
|
|
|
|
|
|
|
); |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
sub _cldr_to_strftime { |
426
|
0
|
|
|
0
|
|
|
shift; |
427
|
0
|
|
|
|
|
|
my $simple = shift; |
428
|
|
|
|
|
|
|
|
429
|
0
|
|
|
|
|
|
$simple |
430
|
|
|
|
|
|
|
=~ s/(G+|y+|u+|M+|d+|h+|H+|m+|s+|S+|E+|D+|F+|w+|W+|a+|k+|K+|z+)|'((?:[^']|'')*)'/ |
431
|
0
|
0
|
|
|
|
|
$2 ? _stringify($2) : $1 ? _convert($1) : "'"/eg; |
|
|
0
|
|
|
|
|
|
432
|
|
|
|
|
|
|
|
433
|
0
|
|
|
|
|
|
return $simple; |
434
|
|
|
|
|
|
|
} |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
sub _convert { |
437
|
0
|
|
|
0
|
|
|
my $simple = shift; |
438
|
|
|
|
|
|
|
|
439
|
0
|
|
|
|
|
|
for ( my $x = 0; $x < @JavaPatterns; $x += 2 ) { |
440
|
0
|
0
|
|
|
|
|
return '%' . $JavaPatterns[ $x + 1 ] |
441
|
|
|
|
|
|
|
if $simple =~ /$JavaPatterns[$x]/; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
0
|
|
|
|
|
|
die "**Dont know $simple***"; |
445
|
|
|
|
|
|
|
} |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
sub _stringify { |
448
|
0
|
|
|
0
|
|
|
my $string = shift; |
449
|
|
|
|
|
|
|
|
450
|
0
|
|
|
|
|
|
$string =~ s/%(?:[^%])/%%/g; |
451
|
0
|
|
|
|
|
|
$string =~ s/\'\'/\'/g; |
452
|
|
|
|
|
|
|
|
453
|
0
|
|
|
|
|
|
return $string; |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
} |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
# end backwards compat |
458
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
sub STORABLE_freeze { |
460
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
461
|
0
|
|
|
|
|
|
my $cloning = shift; |
462
|
|
|
|
|
|
|
|
463
|
0
|
0
|
|
|
|
|
return if $cloning; |
464
|
|
|
|
|
|
|
|
465
|
0
|
|
|
|
|
|
return $self->id(); |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
sub STORABLE_thaw { |
469
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
470
|
0
|
|
|
|
|
|
shift; |
471
|
0
|
|
|
|
|
|
my $serialized = shift; |
472
|
|
|
|
|
|
|
|
473
|
0
|
|
|
|
|
|
my $obj = DateTime::Locale->load($serialized); |
474
|
|
|
|
|
|
|
|
475
|
0
|
|
|
|
|
|
%$self = %$obj; |
476
|
|
|
|
|
|
|
|
477
|
0
|
|
|
|
|
|
return $self; |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
1; |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
# ABSTRACT: Base class for individual locale objects (deprecated) |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
__END__ |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=pod |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
=encoding UTF-8 |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
=head1 NAME |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
DateTime::Locale::Base - Base class for individual locale objects (deprecated) |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
=head1 VERSION |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
version 1.39 |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head1 SYNOPSIS |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
use base 'DateTime::Locale::Base'; |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
=head1 DESCRIPTION |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
B<This module is no longer used by the code in the distribution.> It is still |
505
|
|
|
|
|
|
|
included for the sake of any code out in the wild that may subclass this class. |
506
|
|
|
|
|
|
|
This class will be removed in a future release. |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=head1 DEFAULT FORMATS |
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
Each locale has a set of four default date and time formats. They are |
511
|
|
|
|
|
|
|
distinguished by length, and are called "full", "long", "medium", and "short". |
512
|
|
|
|
|
|
|
Each locale may have a different default length which it uses when its C<< |
513
|
|
|
|
|
|
|
$locale->date_format_default() >>, C<< $locale->time_format_default() >>, or |
514
|
|
|
|
|
|
|
C<< $locale->datetime_format_default() >> methods are called. |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
This can be changed by calling the C<< $locale->set_default_date_format() >> or |
517
|
|
|
|
|
|
|
C<< $locale->set_default_time_format() >> methods. These methods accept a |
518
|
|
|
|
|
|
|
string which must be one of "full", "long", "medium", or "short". |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=head1 NAME FORMS |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
Most names come in a number of variations. First, they may vary based on |
523
|
|
|
|
|
|
|
length, with wide, abbreviated, and narrow forms. The wide form is typically |
524
|
|
|
|
|
|
|
the full name, while the narrow form is often a single character. The narrow |
525
|
|
|
|
|
|
|
forms may not be unique. For example, "T" may be used for Tuesday and Thursday |
526
|
|
|
|
|
|
|
in the English narrow forms. |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
Many names also distinguish between "format" and "stand-alone" forms of a |
529
|
|
|
|
|
|
|
pattern. The format pattern is used when the thing in question is being placed |
530
|
|
|
|
|
|
|
into a larger string. The stand-alone form is used when displaying that item by |
531
|
|
|
|
|
|
|
itself, for example in a calendar. |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=head1 METHODS |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
All locales provide the following methods: |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
=over 4 |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=item * $locale->id() |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
The locale's id. |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
=item * $locale->language_id() |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
The language portion of the id. |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
=item * $locale->script_id() |
548
|
|
|
|
|
|
|
|
549
|
|
|
|
|
|
|
The script portion of the id, if any. |
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=item * $locale->territory_id() |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
The territory portion of the id, if any. |
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=item * $locale->variant_id() |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
The variant portion of the id, if any. |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
=item * $locale->name() |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
The full name for the locale in English. |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
=item * $locale->language() |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
The language name for the locale in English. |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
=item * $locale->script() |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
The script name for the locale in English, if any. |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
=item * $locale->territory() |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
The territory name for the locale in English, if any. |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
=item * $locale->variant() |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
The variant name for the locale in English, if any. |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
=item * $locale->native_name() |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
The full name for the locale in its native language, if any. |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
=item * $locale->native_language() |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
The language name for the locale in its native language, if any. |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=item * $locale->native_script() |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
The script name for the locale in its native language, if any. |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=item * $locale->native_territory() |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
The territory name for the locale in its native language, if any. |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=item * $locale->native_variant() |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
The variant name for the locale in its native language, if any. |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=item * $locale->month_format_wide() |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
Returns an array reference containing the wide format names of the months, with |
602
|
|
|
|
|
|
|
January as the first month. |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
=item * $locale->month_format_abbreviated() |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated format names of the |
607
|
|
|
|
|
|
|
months, with January as the first month. |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=item * $locale->month_format_narrow() |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
Returns an array reference containing the narrow format names of the months, |
612
|
|
|
|
|
|
|
with January as the first month. |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
=item * $locale->month_stand_alone_wide() |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
Returns an array reference containing the wide stand-alone names of the months, |
617
|
|
|
|
|
|
|
with January as the first month. |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=item * $locale->month_stand_alone_abbreviated() |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated stand-alone names of the |
622
|
|
|
|
|
|
|
months, with January as the first month. |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
=item * $locale->month_stand_alone_narrow() |
625
|
|
|
|
|
|
|
|
626
|
|
|
|
|
|
|
Returns an array reference containing the narrow stand-alone names of the |
627
|
|
|
|
|
|
|
months, with January as the first month. |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
=item * $locale->day_format_wide() |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
Returns an array reference containing the wide format names of the days, with |
632
|
|
|
|
|
|
|
Monday as the first day. |
633
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
=item * $locale->day_format_abbreviated() |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated format names of the days, |
637
|
|
|
|
|
|
|
with Monday as the first day. |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=item * $locale->day_format_narrow() |
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
Returns an array reference containing the narrow format names of the days, with |
642
|
|
|
|
|
|
|
Monday as the first day. |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
=item * $locale->day_stand_alone_wide() |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
Returns an array reference containing the wide stand-alone names of the days, |
647
|
|
|
|
|
|
|
with Monday as the first day. |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
=item * $locale->day_stand_alone_abbreviated() |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated stand-alone names of the |
652
|
|
|
|
|
|
|
days, with Monday as the first day. |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
=item * $locale->day_stand_alone_narrow() |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
Returns an array reference containing the narrow stand-alone names of the days, |
657
|
|
|
|
|
|
|
with Monday as the first day. |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
=item * $locale->quarter_format_wide() |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
Returns an array reference containing the wide format names of the quarters. |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
=item * $locale->quarter_format_abbreviated() |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated format names of the |
666
|
|
|
|
|
|
|
quarters. |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
=item * $locale->quarter_format_narrow() |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
Returns an array reference containing the narrow format names of the quarters. |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
=item * $locale->quarter_stand_alone_wide() |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
Returns an array reference containing the wide stand-alone names of the |
675
|
|
|
|
|
|
|
quarters. |
676
|
|
|
|
|
|
|
|
677
|
|
|
|
|
|
|
=item * $locale->quarter_stand_alone_abbreviated() |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated stand-alone names of the |
680
|
|
|
|
|
|
|
quarters. |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
=item * $locale->quarter_stand_alone_narrow() |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
Returns an array reference containing the narrow stand-alone names of the |
685
|
|
|
|
|
|
|
quarters. |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
=item * $locale->era_wide() |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
Returns an array reference containing the wide names of the eras, with "BCE" |
690
|
|
|
|
|
|
|
first. |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
=item * $locale->era_abbreviated() |
693
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated names of the eras, with |
695
|
|
|
|
|
|
|
"BCE" first. |
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
=item * $locale->era_narrow() |
698
|
|
|
|
|
|
|
|
699
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated names of the eras, with |
700
|
|
|
|
|
|
|
"BCE" first. However, most locales do not differ between the narrow and |
701
|
|
|
|
|
|
|
abbreviated length of the era. |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
=item * $locale->am_pm_abbreviated() |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
Returns an array reference containing the abbreviated names of "AM" and "PM". |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
=item * $locale->date_format_long() |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
=item * $locale->date_format_full() |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
=item * $locale->date_format_medium() |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
=item * $locale->date_format_short() |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
Returns the CLDR date pattern of the appropriate length. |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
=item * $locale->date_formats() |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
Returns a hash reference of CLDR date patterns for the date formats, where the |
720
|
|
|
|
|
|
|
keys are "full", "long", "medium", and "short". |
721
|
|
|
|
|
|
|
|
722
|
|
|
|
|
|
|
=item * $locale->time_format_long() |
723
|
|
|
|
|
|
|
|
724
|
|
|
|
|
|
|
=item * $locale->time_format_full() |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
=item * $locale->time_format_medium() |
727
|
|
|
|
|
|
|
|
728
|
|
|
|
|
|
|
=item * $locale->time_format_short() |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
Returns the CLDR date pattern of the appropriate length. |
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
=item * $locale->time_formats() |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
Returns a hash reference of CLDR date patterns for the time formats, where the |
735
|
|
|
|
|
|
|
keys are "full", "long", "medium", and "short". |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
=item * $locale->datetime_format_long() |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
=item * $locale->datetime_format_full() |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
=item * $locale->datetime_format_medium() |
742
|
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
=item * $locale->datetime_format_short() |
744
|
|
|
|
|
|
|
|
745
|
|
|
|
|
|
|
Returns the CLDR date pattern of the appropriate length. |
746
|
|
|
|
|
|
|
|
747
|
|
|
|
|
|
|
=item * $locale->datetime_formats() |
748
|
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
Returns a hash reference of CLDR date patterns for the datetime formats, where |
750
|
|
|
|
|
|
|
the keys are "full", "long", "medium", and "short". |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
=item * $locale->date_format_default() |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
=item * $locale->time_format_default() |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
=item * $locale->datetime_format_default() |
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
Returns the default CLDR date pattern. The length of this format is based on |
759
|
|
|
|
|
|
|
the value of C<< $locale->default_date_format_length() >> and/or C<< |
760
|
|
|
|
|
|
|
$locale->default_time_format_length() >>. |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
=item * $locale->default_date_format_length() |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
=item * $locale->default_time_format_length() |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
Returns the default length for the format, one of "full", "long", "medium", or |
767
|
|
|
|
|
|
|
"short". |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
=item * $locale->set_default_date_format_length() |
770
|
|
|
|
|
|
|
|
771
|
|
|
|
|
|
|
=item * $locale->set_default_time_format_length() |
772
|
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
Sets the default length for the format. This must be one of "full", "long", |
774
|
|
|
|
|
|
|
"medium", or "short". |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
=item * $locale->prefers_24_hour_time() |
777
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
Returns a boolean indicating the preferred hour format for this locale. |
779
|
|
|
|
|
|
|
|
780
|
|
|
|
|
|
|
=item * $locale->first_day_of_week() |
781
|
|
|
|
|
|
|
|
782
|
|
|
|
|
|
|
Returns a number from 1 to 7 indicating the I<local> first day of the week, |
783
|
|
|
|
|
|
|
with Monday being 1 and Sunday being 7. For example, for a US locale this |
784
|
|
|
|
|
|
|
returns 7. |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
=item * $locale->available_formats() |
787
|
|
|
|
|
|
|
|
788
|
|
|
|
|
|
|
A list of format names, like "MMdd" or "yyyyMM". This should be the list |
789
|
|
|
|
|
|
|
directly supported by the subclass, not its parents. |
790
|
|
|
|
|
|
|
|
791
|
|
|
|
|
|
|
=item * $locale->format_for($key) |
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
Given a valid name, returns the CLDR date pattern for that thing, if one |
794
|
|
|
|
|
|
|
exists. |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
=back |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
=head1 SUPPORT |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
See L<DateTime::Locale>. |
801
|
|
|
|
|
|
|
|
802
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/DateTime-Locale/issues>. |
803
|
|
|
|
|
|
|
|
804
|
|
|
|
|
|
|
There is a mailing list available for users of this distribution, |
805
|
|
|
|
|
|
|
L<mailto:datetime@perl.org>. |
806
|
|
|
|
|
|
|
|
807
|
|
|
|
|
|
|
=head1 SOURCE |
808
|
|
|
|
|
|
|
|
809
|
|
|
|
|
|
|
The source code repository for DateTime-Locale can be found at L<https://github.com/houseabsolute/DateTime-Locale>. |
810
|
|
|
|
|
|
|
|
811
|
|
|
|
|
|
|
=head1 AUTHOR |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
814
|
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
This software is copyright (c) 2003 - 2023 by Dave Rolsky. |
818
|
|
|
|
|
|
|
|
819
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
820
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
The full text of the license can be found in the |
823
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
824
|
|
|
|
|
|
|
|
825
|
|
|
|
|
|
|
=cut |