File Coverage

blib/lib/DateTime/Calendar/FrenchRevolutionary/Locale/es.pm
Criterion Covered Total %
statement 65 69 94.2
branch 4 4 100.0
condition n/a
subroutine 38 42 90.4
pod 33 36 91.6
total 140 151 92.7


line stmt bran cond sub pod time code
1             # -*- encoding: utf-8; indent-tabs-mode: nil -*-
2             #
3             # Perl DateTime extension for providing Spanish strings for the French Revolutionary calendar
4             # Copyright (c) 2021 Jean Forget. All rights reserved.
5             #
6             # See the license in the embedded documentation below.
7             #
8              
9             package DateTime::Calendar::FrenchRevolutionary::Locale::es;
10              
11 3     3   703 use utf8;
  3         8  
  3         23  
12 3     3   135 use strict;
  3         8  
  3         75  
13 3     3   17 use warnings;
  3         7  
  3         128  
14 3     3   18 use vars qw($VERSION);
  3         7  
  3         5510  
15              
16             $VERSION = '0.17'; # same as parent module DT::C::FR
17              
18             my @months_short = qw (Vnd Bru Fri Niv Plu Vnt Ger Flo Pra Mes Ter Fru D-C);
19              
20             # based on Gibus' App::SpreadRevolutionaryDate, itself
21             # based on Wikipedia: L<https://es.wikipedia.org/wiki/Calendario_republicano_franc%C3%A9s>.
22             my @months = qw(Vendimiario Brumario Frimario
23             Nivoso Pluvioso Ventoso
24             Germinal Floreal Pradial
25             Mesidor Termidor Fructidor
26             );
27              
28             push @months, 'día complementario';
29              
30             my @decade_days = qw (Primidi Duodi Tridi Quartidi Quintidi Sextidi Septidi Octidi Nonidi Décadi);
31             my @decade_days_short = qw (Pri Duo Tri Qua Qui Sex Sep Oct Non Déc);
32              
33             my @am_pms = qw(AM PM);
34              
35             my $date_before_time = "1";
36             my $default_date_format_length = "medium";
37             my $default_time_format_length = "medium";
38             my $date_parts_order = "dmy";
39              
40             my %date_formats = (
41             "short" => "\%d\/\%m\/\%Y",
42             "medium" => "\%a\ \%d\ \%b\ \%Y",
43             "long" => "\%A\ \%d\ \%B\ \%EY",
44             "full" => "\%A\ \%d\ \%B\ \%EY\,\ \%{feast_long\}",
45             );
46              
47             my %time_formats = (
48             "short" => "\%H\:\%M",
49             "medium" => "\%H\:\%M\:\%S",
50             "long" => "\%H\:\%M\:\%S",
51             "full" => "\%H\ h\ \%M\ mn \%S\ s",
52             );
53              
54             # When initializing an array with lists within lists, it means one of two things:
55             # Either it is a newbie who does not know how to make multi-dimensional arrays,
56             # Or it is a (at least mildly) experienced Perl-coder who, for some reason,
57             # wants to initialize a flat array with the concatenation of lists.
58             # I am a (at least mildly) experienced programmer who wants to use qw() and yet insert
59             # comments in some places.
60             # This array is mainly based on Gibus' App::SpreadRevolutionaryDate, itself
61             # based on Wikipedia: L<https://es.wikipedia.org/wiki/Calendario_republicano_franc%C3%A9s>.
62             my @feast = (
63             # Vendémiaire
64             qw(
65             1uva 0azafrán 1castaña 1cólquida 0caballo
66             1balsamina 1zanahoria 0amaranto 1chirivía 1tinaja
67             1patata 1flor_de_papel 1calabaza 1reseda 0asno
68             1bella_de_noche 1calabaza_otoñal 0alforfón 0girasol 0lagar
69             0cáñamo 0melocotón 0nabo 1amarilis 0buey
70             1berenjena 0pimiento 0tomate 1cebada 0barril
71             ),
72             # Brumaire
73             qw(
74             1manzana 0apio 1pera 1remolacha 1oca
75             0heliótropo 0higo 1escorzonera 0mostajo 0arado
76             1salsifí 1castaña_de_agua 0tupinambo 1endibia 0guajolote
77             1escaravía 0berro 1dentelaria 1granada 1grada
78             1bacante 0acerolo 1rubia_roja 1naranja 0faisán
79             0pistacho 0lathyrus_tuberosus 0membrillo 0serbal 0rodillo
80             ),
81             # Frimaire
82             qw(
83             0rapónchigo 0nabo_forrajero 1achicoria 0níspero 0cerdo
84             0canónigo 1coliflor 1miel 0enebro 0pico
85             1cera 0rábano_picante 0cedro 0abeto 0corzo
86             0tojo 1ciprés 1hiedra 1sabina 0azadón
87             0arce 0brezo 1caña 1acedera 0grillo
88             1piñón 0corcho 1trufa 1aceituna 1pala
89             ),
90             # Nivôse
91             qw(
92             1turba 0carbón 0betún 0azufre 1perro
93             1lava 0suelo 1estiércol 0salitre 0mayal
94             0granito 1arcilla 1pizarra 1arenisca 0conejo
95             1sílex 1marga 1caliza 0mármol 1aventadora_de_cereal
96             1piedra_de_yeso 1sal 0hierro 0cobre 1gato
97             0estaño 0plomo 0cinc 0mercurio 0tamiz
98             ),
99             # Pluviôse
100             qw(
101             1laureola 0musgo 0rusco 0galanto 0toro
102             0laurentino 0hongo_yesquero 0mezereón 0álamo 0hacha
103             0eléboro 1brécol 0laurel 0avellano 1vaca
104             0boj 0liquen 0tejo 1pulmonaria 1navaja_podadora
105             0carraspique 0torvisco 1gramilla 1centinodia 1liebre
106             1isatide 0avellano 0ciclamen 1celidonia_mayor 0trineo
107             ),
108             # Ventôse
109             qw(
110             0tusilago 0corno 0alhelí 0aligustre 0macho_cabrío
111             0jengibre_silvestre 0aladierno 0violeta 1sauce_cabruno 1laya
112             0narciso 0olmo 1fumaria 0erísimo 1cabra
113             1espinaca 0doronicum 1anagallis 0perifollo 0hilo
114             1mandrágora 0perejil 1coclearia 1margarita 0atún
115             0diente_de_león 1anémona_de_bosque 0culantrillo 0fresno 0plantador
116             ),
117             # Germinal
118             qw(
119             1primavera 0sicomoro 0espárrago 0tulipán 1gallina
120             1acelga 0abedul 0junquillo 0alnus 0nidal
121             1vincapervinca 0carpe 1morchella 0haya 1abeja
122             1lechuga 0alerce 1cicuta 0rábano 1colmena
123             1árbol_de_Judea 1lechuga_romana 0castaño_de_Indias 1roqueta 1paloma
124             0lila 1anémona 0pensamiento 0arándano 0cuchillo
125             ),
126             # Floréal
127             qw(
128             0rosa 0roble 0helecho 0espino_albar 0ruiseñor
129             1aguileña 1convalaria 1seta 0jacinto 0rastrillo
130             0ruibarbo 1esparceta 0erysimum 0palmito 0gusano_de_seda
131             1consuelda 1algáfita 0alyssum 0atriplex 0escardillo
132             0limonium_sinuatum 1fritillaria 1borraja 1valeriana 1carpa
133             0bonetero 0cebollino 1anchusa 1mostaza_negra 0armuelle
134             ),
135             # Prairial
136             qw(
137             1alfalfa 0lirio_de_día 0trébol 1angélica 0pato
138             0toronjil 1mazorra 0martagón 0serpol 1guadaña
139             1fresa 1salvia 0guisante 1acacia 1codorniz
140             0clavel 0saúco 1adormidera 0tilo 0bieldo
141             0barbo 1manzanilla 1madreselva 0galium 1tenca
142             0jazmín 1verbena 0tomillo 1peonía 0carro
143             ),
144             # Messidor
145             qw(
146             0centeno 1avena 1cebolla 1veronica 1mula
147             1romero 0pepino 0chalote 1absenta 1hoz
148             0cilantro 1alcachofa 0alhelí 1lavanda 1gamuza
149             0tabaco 1grosella 0lathyrus 1cereza 0parque
150             1menta 0comino 1judía 1palomilla_de_tintes 1gallina_de_Guinea
151             1salvia 0ajo 1algarroba 0trigo 1chirimía
152             ),
153             # Thermidor
154             qw(
155             1escanda 0verbasco 0melón 1cizaña 0carnero
156             1cola_de_caballo 1artemisa 0cártamo 1mora 1regadera
157             0panicum 0salicor 0albaricoque 1albahaca 1oveja
158             1malvaceae 0lino 1almendra 1genciana 1esclusa
159             1carlina 1alcaparra 1lenteja 1inula 1nutria
160             0mirto 1colza 0lupino 0algodón 0molino
161             ),
162             # Fructidor
163             qw(
164             1ciruela 0mijo 0soplo_de_lobo 1cebada_de_otoño 0salmón
165             0nardo 1cebada_de_invierno 1apocynaceae 0regaliz 1escala
166             1sandía 0hinojo 0berberis 1nuez 1trucha
167             0limón 1cardencha 0espino_cerval 0clavelón 0cesto
168             0escaramujo 1avellana 1lúpulo 0sorgo 0cangrejo_de_río
169             1naranja_amarga 1vara_de_oro 1maíz 1castaña 1cesta
170             ),
171             # Jours complémentaires
172             qw(
173             1virtud 0talento 0trabajo 1opinión 3recompensas
174             1revolución
175             ));
176             my @prefix = ( 'día del ', 'día de la ', 'día de los ', 'día de las ');
177              
178             my %event = ();
179              
180             sub new {
181 9     9 1 50 return bless {}, $_[0];
182             }
183              
184             sub month_name {
185 6     6 1 14 my ($self, $date) = @_;
186 6         18 return $months[$date->month_0]
187             }
188              
189             sub month_abbreviation {
190 3     3 1 7 my ($self, $date) = @_;
191 3         8 return $months_short[$date->month_0]
192             }
193              
194             sub day_name {
195 8     8 1 17 my ($self, $date) = @_;
196 8         22 return $decade_days[$date->day_of_decade_0];
197             }
198              
199             sub day_abbreviation {
200 5     5 1 12 my ($self, $date) = @_;
201 5         13 return $decade_days_short[$date->day_of_decade_0];
202             }
203              
204 4 100   4 1 11 sub am_pm { $_[0]->am_pms->[ $_[1]->hour < 5 ? 0 : 1 ] }
205              
206             sub _raw_feast {
207 1     1   3 my ($self, $date) = @_;
208 1         3 $feast[$date->day_of_year_0];
209             }
210              
211             sub feast_short {
212 1     1 1 4 my ($self, $date) = @_;
213 1         4 my $lb = $feast[$date->day_of_year_0];
214 1         5 $lb =~ s/^\?//;
215 1         4 $lb =~ s/_/ /g;
216 1         7 return substr($lb, 1);
217             }
218              
219             sub feast_long {
220 1     1 1 3 my ($self, $date) = @_;
221 1         4 my $lb = $feast[$date->day_of_year_0];
222 1         3 $lb =~ s/^\?//;
223 1         3 $lb =~ s/_/ /g;
224 1         8 $lb =~ s/^(\d)/$prefix[$1]/;
225 1         6 return $lb;
226             }
227              
228             sub feast_caps {
229 4     4 1 9 my ($self, $date) = @_;
230 4         13 my $lb = $feast[$date->day_of_year_0];
231 4         13 $lb =~ s/^\?//;
232 4         10 $lb =~ s/_/ /g;
233 4         30 $lb =~ s/^(\d)(.)/\u$prefix[$1]\u$2/;
234 4         19 return $lb;
235             }
236              
237 4     4 1 26 sub full_date_format { $_[0]->date_formats->{full} }
238 4     4 1 16 sub long_date_format { $_[0]->date_formats->{long} }
239 4     4 1 15 sub medium_date_format { $_[0]->date_formats->{medium} }
240 4     4 1 15 sub short_date_format { $_[0]->date_formats->{short} }
241 4     4 1 14 sub default_date_format { $_[0]->date_formats->{ $_[0]->default_date_format_length } }
242              
243 4     4 1 13 sub full_time_format { $_[0]->time_formats->{full} }
244 4     4 1 13 sub long_time_format { $_[0]->time_formats->{long} }
245 4     4 1 12 sub medium_time_format { $_[0]->time_formats->{medium} }
246 4     4 1 13 sub short_time_format { $_[0]->time_formats->{short} }
247 4     4 1 12 sub default_time_format { $_[0]->time_formats->{ $_[0]->default_time_format_length } }
248              
249 10 100   10   21 sub _datetime_format_pattern_order { $_[0]->date_before_time ? (0, 1) : (1, 0) }
250              
251 2     2 1 11 sub full_datetime_format { join ' ', ( $_[0]-> full_date_format, $_[0]-> full_time_format )[ $_[0]->_datetime_format_pattern_order ] }
252 2     2 1 10 sub long_datetime_format { join ' ', ( $_[0]-> long_date_format, $_[0]-> long_time_format )[ $_[0]->_datetime_format_pattern_order ] }
253 2     2 1 9 sub medium_datetime_format { join ' ', ( $_[0]-> medium_date_format, $_[0]-> medium_time_format )[ $_[0]->_datetime_format_pattern_order ] }
254 2     2 1 9 sub short_datetime_format { join ' ', ( $_[0]-> short_date_format, $_[0]-> short_time_format )[ $_[0]->_datetime_format_pattern_order ] }
255 2     2 1 9 sub default_datetime_format { join ' ', ( $_[0]->default_date_format, $_[0]->default_time_format )[ $_[0]->_datetime_format_pattern_order ] }
256              
257 4     4 1 10 sub default_date_format_length { $default_date_format_length }
258 4     4 1 11 sub default_time_format_length { $default_time_format_length }
259              
260 0     0 1 0 sub month_names { [ @months ] }
261 0     0 1 0 sub month_abbreviations { [ @months_short ] }
262 0     0 1 0 sub day_names { [ @decade_days ] }
263 0     0 1 0 sub day_abbreviations { [ @decade_days_short ] }
264 4     4 0 15 sub am_pms { [ @am_pms ] }
265 20     20 1 49 sub date_formats { \%date_formats }
266 20     20 1 59 sub time_formats { \%time_formats }
267 5     5 0 27 sub date_before_time { $date_before_time }
268 2     2 0 6 sub date_parts_order { $date_parts_order }
269              
270             sub on_date {
271 1     1 1 4 return '';
272             }
273              
274             # A module must return a true value. Traditionally, a module returns 1.
275             # But this module is a revolutionary one, so it discards all old traditions.
276             "Ah ! ça ira ! ça ira !";
277              
278             __END__
279              
280             =encoding utf8
281              
282             =head1 NAME
283              
284             DateTime::Calendar::FrenchRevolutionary::Locale::es -- Spanish localization for the French
285             revolutionary calendar.
286              
287             =head1 SYNOPSIS
288              
289             use DateTime::Calendar::FrenchRevolutionary::Locale;
290             my $spanish_locale = DateTime::Calendar::FrenchRevolutionary::Locale->load('es');
291              
292             my $spanish_month_name =$spanish_locale->month_name($date);
293              
294             =head1 DESCRIPTION
295              
296             This module provides localization for DateTime::Calendar::FrenchRevolutionary.
297             Usually, its methods will be invoked only from DT::C::FR.
298              
299             =head1 USAGE
300              
301             This module provides the following class methods:
302              
303             =over 4
304              
305             =item * new
306              
307             Returns an object instance, which is just a convenient value to be
308             stored in a variable.
309              
310             Contrary to the widely used Gregorian calendar, there is no need to
311             customize a French Revolutionary calendar locale. Therefore, there are
312             no instance data and no instance methods.
313              
314             =item * month_name ($date)
315              
316             Returns an Spanish translation for C<$date>'s month, where C<$date> is
317             a C<DateTime::Calendar::FrenchRevolutionary> object.
318              
319             =item * month_abbreviation ($date)
320              
321             Returns a 3-letter abbreviation for the Spanish month name.
322              
323             =item * day_name ($date)
324              
325             Returns an Spanish translation for the day name.
326              
327             =item * day_abbreviation ($date)
328              
329             Returns a 3-letter abbreviation for the Spanish day name.
330              
331             =item * am_pm ($date)
332              
333             Returns a code (typically C<AM> or C<PM>) showing whether the datetime
334             is in the morning or the afternoon. Outside the sexagesimal time with
335             a 1..12 hour range, this is not very useful.
336              
337             =item * feast_short ($date)
338              
339             Hopefully returns an adequate Spanish translation for the plant,
340             animal or tool that correspond to C<$date>'s feast.
341              
342             Note: in some cases, the feast French name is left untranslated, while
343             in some other cases, the translation is inadequate. If you are fluent
344             in both French and Spanish, do not hesitate to send corrections to the
345             author.
346              
347             =item * feast_long ($date)
348              
349             Same as C<feast_short>, with a "day" prefix.
350              
351             =item * feast_caps ($date)
352              
353             Same as C<feast_long> with capitalized first letters.
354              
355             =item * on_date ($date)
356              
357             Not implemented for the Spanish locale. This method returns an empty string.
358              
359             =item * full_date_format, long_date_format, medium_date_format, short_date_format
360              
361             Class methods, giving four C<strftime> canned formats for dates,
362             without the need to remember all the C<%> specifiers.
363              
364             =item * full_time_format, long_time_format, medium_time_format, short_time_format
365              
366             Same thing, C<strftime> canned formats for decimal time.
367              
368             =item * full_datetime_format, long_datetime_format, medium_datetime_format, short_datetime_format
369              
370             Same thing, for formats including both the date and the decimal time.
371              
372             =item * default_date_format, default_time_format, default_datetime_format
373              
374             Class methods suggesting one each of the date formats, of the time
375             formats and of the datetime formats.
376              
377             =item * full_time_format, long_time_format, medium_time_format, short_time_format
378              
379             Same thing, C<strftime> canned formats for decimal time.
380              
381             =item * full_datetime_format, long_datetime_format, medium_datetime_format, short_datetime_format
382              
383             Same thing, for formats including both the date and the decimal time.
384              
385             =item * default_date_format, default_time_format, default_datetime_format
386              
387             Class methods suggesting one each of the date formats, of the time
388             formats and of the datetime formats.
389              
390             =item * default_date_format_length, default_time_format_length
391              
392             While C<default_date_format> and C<default_time_format> give the
393             actual default formats, with C<%> and all, these class methods give a
394             one-word description of the default formats: C<short>, C<medium>,
395             C<long> or C<full>.
396              
397             =item * date_formats, time_formats
398              
399             These class methods give a hashtable where the key is the length
400             (C<short>, C<medium>, C<long> and C<full>) and the value is the
401             corresponding format, complete with C<%> and specifiers.
402              
403             =item * month_names, month_abbreviations, day_names, day_abbreviations
404              
405             Class methods giving the whole array of month or day names or abbrevs,
406             not limited to the date implemented by the invocant.
407              
408             =back
409              
410             =head1 SUPPORT
411              
412             Support for this module is provided via the datetime@perl.org email
413             list. See L<https://lists.perl.org/> for more details.
414              
415             Please report any bugs or feature requests to Github at
416             L<https://github.com/jforget/DateTime-Calendar-FrenchRevolutionary>,
417             and create an issue or submit a pull request.
418              
419             If you have no feedback after a week or so, try to reach me by email
420             at JFORGET at cpan dot org. The notification from Github may have
421             failed to reach me. In your message, please mention the distribution
422             name in the subject, so my spam filter and I will easily dispatch the
423             email to the proper folder.
424              
425             On the other hand, I may be on vacation or away from Internet for a
426             good reason. Do not be upset if I do not answer immediately. You
427             should write me at a leisurely rythm, about once per month, until I
428             react.
429              
430             If after about six months or a year, there is still no reaction from
431             me, you can worry and start the CPAN procedure for module adoption.
432             See L<https://groups.google.com/g/perl.module-authors/c/IPWjASwuLNs>
433             L<https://www.cpan.org/misc/cpan-faq.html#How_maintain_module>
434             and L<https://www.cpan.org/misc/cpan-faq.html#How_adopt_module>.
435              
436             =head1 AUTHOR
437              
438             Jean Forget <JFORGET@cpan.org>
439              
440             =head1 SEE ALSO
441              
442             =head2 Internet
443              
444             L<http://datetime.perl.org/>
445              
446             L<https://es.wikipedia.org/wiki/Calendario_republicano_franc%C3%A9s>
447              
448             =head1 LICENSE STUFF
449              
450             Copyright (c) 2021 Jean Forget. All rights reserved. This program is
451             free software. You can distribute, adapt, modify, and otherwise mangle
452             DateTime::Calendar::FrenchRevolutionary under the same terms as perl
453             5.16.3.
454              
455             This program is distributed under the same terms as Perl 5.16.3: GNU
456             Public License version 1 or later and Perl Artistic License
457              
458             You can find the text of the licenses in the F<LICENSE> file or at
459             L<https://dev.perl.org/licenses/artistic.html> and
460             L<https://www.gnu.org/licenses/old-licenses/gpl-1.0.html>.
461              
462             Here is the summary of GPL:
463              
464             This program is free software; you can redistribute it and/or modify
465             it under the terms of the GNU General Public License as published by
466             the Free Software Foundation; either version 1, or (at your option)
467             any later version.
468              
469             This program is distributed in the hope that it will be useful, but
470             WITHOUT ANY WARRANTY; without even the implied warranty of
471             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
472             General Public License for more details.
473              
474             You should have received a copy of the GNU General Public License
475             along with this program; if not, see L<https://www.gnu.org/licenses/>
476             or contact the Free Software Foundation, Inc., L<https://www.fsf.org>.
477              
478             =cut