line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::Flexible::lang::es; |
2
|
|
|
|
|
|
|
|
3
|
20
|
|
|
20
|
|
226
|
use strict; |
|
20
|
|
|
|
|
232
|
|
|
20
|
|
|
|
|
568
|
|
4
|
20
|
|
|
20
|
|
113
|
use warnings; |
|
20
|
|
|
|
|
47
|
|
|
20
|
|
|
|
|
16527
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new |
7
|
|
|
|
|
|
|
{ |
8
|
0
|
|
|
0
|
1
|
0
|
my ( $class , %params ) = @_; |
9
|
0
|
|
|
|
|
0
|
my $self = bless \%params , $class; |
10
|
0
|
|
|
|
|
0
|
return $self; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub months |
14
|
|
|
|
|
|
|
{ |
15
|
|
|
|
|
|
|
# http://llts.stanford.edu/months.html |
16
|
|
|
|
|
|
|
# http://www.tarver-genealogy.net/aids/spanish/sp_dates_num.html#days |
17
|
|
|
|
|
|
|
return ( |
18
|
7344
|
|
|
7344
|
1
|
104831
|
qr{enero|enro|eno}i => 1, |
19
|
|
|
|
|
|
|
qr{febr(?:ero)?|febo}i => 2, |
20
|
|
|
|
|
|
|
qr{marzo|mzo}i => 3, |
21
|
|
|
|
|
|
|
qr{abr(?:il)?|abl}i => 4, |
22
|
|
|
|
|
|
|
qr{\bmayo\b}i => 5, |
23
|
|
|
|
|
|
|
qr{jun(?:io)?}i => 6, |
24
|
|
|
|
|
|
|
qr{jul(?:io)?}i => 7, |
25
|
|
|
|
|
|
|
qr{agosto|agto}i => 8, |
26
|
|
|
|
|
|
|
qr{sept(?:iembre)}i => 9, |
27
|
|
|
|
|
|
|
qr{septe|set}i => 9, |
28
|
|
|
|
|
|
|
qr{oct(?:ubre)?}i => 10, |
29
|
|
|
|
|
|
|
qr{nov(?:iembre)?}i => 11, |
30
|
|
|
|
|
|
|
qr{novbre}i => 11, |
31
|
|
|
|
|
|
|
qr{dic(?:iembre)?}i => 12, |
32
|
|
|
|
|
|
|
qr{dice}i => 12, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub days |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
# http://www.tarver-genealogy.net/aids/spanish/sp_dates_num.html#days |
39
|
|
|
|
|
|
|
return [ |
40
|
7344
|
|
|
7344
|
1
|
43446
|
{q{lunes} => 1}, # Monday |
41
|
|
|
|
|
|
|
{q{martes} => 2}, # Tuesday |
42
|
|
|
|
|
|
|
{q{miércoles} => 3}, # Wednesday |
43
|
|
|
|
|
|
|
{q{jueves} => 4}, # Thursday |
44
|
|
|
|
|
|
|
{q{viernes} => 5}, # Friday |
45
|
|
|
|
|
|
|
{q{sábado} => 6}, # Saturday |
46
|
|
|
|
|
|
|
{q{domingo} => 7}, # Sunday |
47
|
|
|
|
|
|
|
]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub day_numbers |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
# http://www.tarver-genealogy.net/aids/spanish/sp_dates_num.html#days |
53
|
|
|
|
|
|
|
return ( |
54
|
3672
|
|
|
3672
|
1
|
69191
|
q{primero} => 1, # first |
55
|
|
|
|
|
|
|
q{segundo} => 2, # second |
56
|
|
|
|
|
|
|
q{tercero} => 3, # third |
57
|
|
|
|
|
|
|
q{cuarto} => 4, # fourth |
58
|
|
|
|
|
|
|
q{quinto} => 5, # fifth |
59
|
|
|
|
|
|
|
q{sexto} => 6, # sixth |
60
|
|
|
|
|
|
|
q{septimo} => 7, # seventh |
61
|
|
|
|
|
|
|
q{octavo} => 8, # eighth |
62
|
|
|
|
|
|
|
q{nono|noveno} => 9, # ninth |
63
|
|
|
|
|
|
|
q{decimo} => 10, # tenth |
64
|
|
|
|
|
|
|
q{undecimo} => 11, # eleventh |
65
|
|
|
|
|
|
|
q{decimoprimero} => 11, # eleventh |
66
|
|
|
|
|
|
|
q{duodecimo} => 12, # twelfth |
67
|
|
|
|
|
|
|
q{decimosegundo} => 12, # twelfth |
68
|
|
|
|
|
|
|
q{decimotercero} => 13, # thirteenth |
69
|
|
|
|
|
|
|
q{decimocuarto} => 14, # fourteenth |
70
|
|
|
|
|
|
|
q{decimoquinto} => 15, # fifteenth |
71
|
|
|
|
|
|
|
q{decimosexto} => 16, # sixteenth |
72
|
|
|
|
|
|
|
q{decimo septimo} => 17, # seventeenth |
73
|
|
|
|
|
|
|
q{decimoctavo} => 18, # eithteenth |
74
|
|
|
|
|
|
|
q{decimonono} => 19, # ninteenth |
75
|
|
|
|
|
|
|
q{vigesimo} => 20, # twentieth |
76
|
|
|
|
|
|
|
q{vigesimo primero} => 21, # twenty first |
77
|
|
|
|
|
|
|
q{vigesimo segundo} => 22, # twenty second |
78
|
|
|
|
|
|
|
q{vigesimo tercero} => 23, # twenty third |
79
|
|
|
|
|
|
|
q{vigesimo cuarto} => 24, # twenty fourth |
80
|
|
|
|
|
|
|
q{veinticuatro} => 24, # twenty four |
81
|
|
|
|
|
|
|
q{vigesimo quinto} => 25, # twenty fifth |
82
|
|
|
|
|
|
|
q{vigesimo sexto} => 26, # twenty sixth |
83
|
|
|
|
|
|
|
q{vigesimo septimo} => 27, # twenty seventh |
84
|
|
|
|
|
|
|
q{vigesimo octavo} => 28, # twenty eighth |
85
|
|
|
|
|
|
|
q{vigesimo nono} => 29, # twenty ninth |
86
|
|
|
|
|
|
|
q{trigesimo} => 30, # thirtieth |
87
|
|
|
|
|
|
|
q{trigesimo primero} => 31, # thirty first |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub hours |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
return ( |
94
|
3672
|
|
|
3672
|
1
|
13009
|
mediodia => '12:00:00', # noon |
95
|
|
|
|
|
|
|
medianoche => '00:00:00', # midnight |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub remove_strings |
100
|
|
|
|
|
|
|
{ |
101
|
|
|
|
|
|
|
return ( |
102
|
3672
|
|
|
3672
|
1
|
12153
|
qr{\bde\b}i, # remove ' de ' as in '29 de febrero de 1996' |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub parse_time |
107
|
|
|
|
|
|
|
{ |
108
|
3672
|
|
|
3672
|
1
|
6992
|
my ( $self, $date ) = @_; |
109
|
3672
|
|
|
|
|
6953
|
return $date; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub string_dates |
113
|
|
|
|
|
|
|
{ |
114
|
3672
|
|
|
3672
|
1
|
10587
|
my $base_dt = DateTime::Format::Flexible->base; |
115
|
|
|
|
|
|
|
return ( |
116
|
0
|
|
|
0
|
|
0
|
ahora => sub { return $base_dt->datetime }, # now |
117
|
0
|
|
|
0
|
|
0
|
hoy => sub { return $base_dt->clone->truncate( to => 'day' )->ymd } , # today |
118
|
0
|
|
|
0
|
|
0
|
manana => sub { return $base_dt->clone->truncate( to => 'day' )->add( days => 1 )->ymd }, # tomorrow |
119
|
0
|
|
|
0
|
|
0
|
ayer => sub { return $base_dt->clone->truncate( to => 'day' )->subtract( days => 1 )->ymd }, # yesterday |
120
|
0
|
|
|
0
|
|
0
|
'pasado manana' => sub { return DateTime->today->add( days => 2 )->ymd }, # overmorrow (the day after tomorrow) |
121
|
1
|
|
|
1
|
|
3
|
epoca => sub { return DateTime->from_epoch( epoch => 0 ) }, |
122
|
0
|
|
|
0
|
|
0
|
'-infinito' => sub { return '-infinity' }, |
123
|
2
|
|
|
2
|
|
5
|
infinito => sub { return 'infinity' }, |
124
|
3672
|
|
|
|
|
901119
|
); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub relative |
128
|
|
|
|
|
|
|
{ |
129
|
|
|
|
|
|
|
return ( |
130
|
|
|
|
|
|
|
# as in 3 years ago, -3 years |
131
|
3672
|
|
|
3672
|
1
|
23843
|
ago => qr{\bhace\b|\A\-}i, |
132
|
|
|
|
|
|
|
# as in 3 years from now, +3 years |
133
|
|
|
|
|
|
|
from => qr{\ba\b\s\bpartir\b\s\bde\b\s\bahora\b|\A\+}i, |
134
|
|
|
|
|
|
|
# as in next Monday |
135
|
|
|
|
|
|
|
next => qr{\bsiguiente\b}i, |
136
|
|
|
|
|
|
|
# as in last Monday |
137
|
|
|
|
|
|
|
last => qr{\bpasado\b}i, |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub math_strings |
142
|
|
|
|
|
|
|
{ |
143
|
|
|
|
|
|
|
return ( |
144
|
1
|
|
|
1
|
1
|
11
|
ano => 'years' , |
145
|
|
|
|
|
|
|
anos => 'years' , |
146
|
|
|
|
|
|
|
'años' => 'years' , |
147
|
|
|
|
|
|
|
mes => 'months' , |
148
|
|
|
|
|
|
|
meses => 'months' , |
149
|
|
|
|
|
|
|
dia => 'days' , |
150
|
|
|
|
|
|
|
dias => 'days' , |
151
|
|
|
|
|
|
|
hora => 'hours' , |
152
|
|
|
|
|
|
|
horas => 'hours' , |
153
|
|
|
|
|
|
|
minuto => 'minutes' , |
154
|
|
|
|
|
|
|
minutos => 'minutes' , |
155
|
|
|
|
|
|
|
semana => 'weeks', |
156
|
|
|
|
|
|
|
semanas => 'weeks', |
157
|
|
|
|
|
|
|
); |
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
sub timezone_map |
161
|
|
|
|
|
|
|
{ |
162
|
|
|
|
|
|
|
# http://home.tiscali.nl/~t876506/TZworld.html |
163
|
|
|
|
|
|
|
return ( |
164
|
3672
|
|
|
3672
|
1
|
18848
|
CET => 'Europe/Madrid', |
165
|
|
|
|
|
|
|
CEST => 'Europe/Madrid', |
166
|
|
|
|
|
|
|
CST => 'America/Cancun', |
167
|
|
|
|
|
|
|
CDT => 'America/Cancun', |
168
|
|
|
|
|
|
|
MST => 'America/Chihuahua', |
169
|
|
|
|
|
|
|
MDT => 'America/Chihuahua', |
170
|
|
|
|
|
|
|
PST => 'America/Tijuana', |
171
|
|
|
|
|
|
|
PDT => 'America/Tijuana', |
172
|
|
|
|
|
|
|
); |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |
176
|
|
|
|
|
|
|
__END__ |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=encoding utf-8 |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 NAME |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
DateTime::Format::Flexible::lang::es - spanish language plugin |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 DESCRIPTION |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
You should not need to use this module directly. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
If you only want to use one language, specify the lang property when parsing a date. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
example: |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
my $dt = DateTime::Format::Flexible->parse_datetime( |
193
|
|
|
|
|
|
|
'29 de febrero de 1996' , |
194
|
|
|
|
|
|
|
lang => ['es'] |
195
|
|
|
|
|
|
|
); |
196
|
|
|
|
|
|
|
# $dt is now 1996-02-29T00:00:00 |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Note that this is not required, by default ALL languages are scanned when trying to parse a date. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 new |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Instantiate a new instance of this module. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 months |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
month name regular expressions along with the month numbers (enero|enro|eno => 1) |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 days |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
day name regular expressions along the the day numbers (lunes => 1) |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 day_numbers |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
maps day of month names to the corresponding numbers (primero => 01) |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head2 hours |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
maps hour names to numbers (ediodia => 12:00:00) |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head2 remove_strings |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
strings to remove from the date (de as in cinco de mayo) |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head2 parse_time |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
currently does nothing |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=head2 string_dates |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
maps string names to real dates (ahora => DateTime->now) |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 relative |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
parse relative dates (ago => hace, from => a partir de ahora, next => siguiente, last => pasado) |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 math_strings |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
useful strings when doing datetime math |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 timezone_map |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
maps unofficial timezones to official timezones for this language (PDT => America/Tijuana) |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 AUTHOR |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Tom Heady |
247
|
|
|
|
|
|
|
CPAN ID: thinc |
248
|
|
|
|
|
|
|
Punch, Inc. |
249
|
|
|
|
|
|
|
cpan@punch.net |
250
|
|
|
|
|
|
|
http://www.punch.net/ |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Copyright 2011 Tom Heady. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or |
257
|
|
|
|
|
|
|
modify it under the terms of either: |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=over 4 |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item * the GNU General Public License as published by the Free |
262
|
|
|
|
|
|
|
Software Foundation; either version 1, or (at your option) any |
263
|
|
|
|
|
|
|
later version, or |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item * the Artistic License. |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 SEE ALSO |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
F<DateTime::Format::Flexible> |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |