File Coverage

blib/lib/DateTime/Calendar/FrenchRevolutionary/Locale/it.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 Italian 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::it;
10              
11 3     3   664 use utf8;
  3         10  
  3         24  
12 3     3   104 use strict;
  3         6  
  3         64  
13 3     3   83 use warnings;
  3         8  
  3         117  
14 3     3   17 use vars qw($VERSION);
  3         6  
  3         5516  
15              
16             $VERSION = '0.17'; # same as parent module DT::C::FR
17              
18             my @months_short = qw (Vnd Bru Fri Nev Pio Vnt Ger Fio Pra Mes Ter Fru G-S);
19              
20             # based on Gibus' App::SpreadRevolutionaryDate, itself
21             # based on Wikipedia: L<https://it.wikipedia.org/wiki/Calendario_rivoluzionario_francese>.
22             my @months = qw(Vendemmiaio Brumaio Frimaio
23             Nevoso Piovoso Ventoso
24             Germile Fiorile Pratile
25             Messidoro Termidoro Fruttidoro
26             );
27              
28             push @months, 'giorni supplementari';
29              
30             my @decade_days = qw (Primidi Duodi Tridi Quartidi Quintidi Sestidi Settidi Ottidi Nonidi Decadi);
31             my @decade_days_short = qw (Pri Duo Tri Qua Qui Sex Set Ott Non Dec);
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 https://it.wikipedia.org/wiki/Vendemmiaio
64             qw(
65             2uva 1zafferano 3castagna 0colchico 0cavallo
66             3balsamina 3carota 2amaranto 3pastinaca 0tino
67             3patata 0perpetuino 3zucca 3reseda 2asino
68             3bella_di_notte 3zucca 0grano_saraceno 0girasole 0torchio
69             3canapa 0pesca 3rapa 2amarillide 0bue
70             3melanzana 0peperoncino 0pomodoro 2orzo 0barile
71             ),
72             # Brumaire https://it.wikipedia.org/wiki/Brumaio
73             qw(
74             0mela 0sedano 3pera 3barbabietola 2oca
75             2eliotropio 0fico 3scorzonera 0ciavardello 2aratro
76             3barba_di_becco 3castagna_d'acqua 0topinambur 2indivia 0tacchino
77             0sisaro 0crescione 3piombaggine 0melograno 2erpice
78             0baccaro 2azzeruolo 3robbia 2arancia 0fagiano
79             0pistacchio 3cicerchia 0cotogno 0sorbo 0rullo
80             ),
81             # Frimaire https://it.wikipedia.org/wiki/Frimaio
82             qw(
83             0raponzolo 3rapa 3cicoria 0nespolo 0maiale
84             0soncino 0cavolfiore 0miele 0ginepro 3zappa
85             3cera 0rafano 0cedro 2abete 0capriolo
86             0ginestrone 0cipresso 3edera 3sabina 3ascia
87             2acero_da_zucchero 2erica 3canna 2acetosa 0grillo
88             0pino 0sughero 0tartufo 2oliva 3pala
89             ),
90             # Nivôse https://it.wikipedia.org/wiki/Nevoso
91             qw(
92             3torba 0carbone_bituminoso 0bitume 0zolfo 0cane
93             3lava 3terra_vegetale 0letame 0salnitro 0correggiato
94             0granito 3argilla 2ardesia 2arenaria 0coniglio
95             3selce 3marna 0calcare 0marmo 0setaccio
96             0gesso 0sale 0ferro 0rame 0gatto
97             0stagno 0piombo 0zinco 0mercurio 0colino
98             ),
99             # Pluviôse https://it.wikipedia.org/wiki/Piovoso
100             qw(
101             3dafne_laurella 0muschio 0pungitopo 0bucaneve 0toro
102             0viburno 0fungo_dell'esca 3camalea 0pioppo 1scure
103             0elleboro 0broccolo 2alloro 0nocciolo 3vacca
104             0bosso 0lichene 0tasso 3polmonaria 0coltello_da_potatura
105             0thlaspi 3dafne_odorosa 3gramigna 0centinodio 3lepre
106             0guado 0nocciolo 0ciclamino 3celidonia 3slitta
107             ),
108             # Ventôse https://it.wikipedia.org/wiki/Ventoso
109             qw(
110             3tossillagine 0corniolo 3violacciocca 0ligustro 0caprone
111             0baccaro_comune 2alaterno 3violetta 0salicone 3vanga
112             0narciso 2olmo 3fumaria 2erisimo 3capra
113             0spinacio 0doronico 3primula 0cerfoglio 3corda
114             3mandragola 0prezzemolo 3coclearia 3margherita 0tonno
115             0dente_di_leone 2anemone 0capelvenere 0frassino 0piantatoio
116             ),
117             # Germinal https://it.wikipedia.org/wiki/Germinale
118             qw(
119             3primula 0platano 2asparago 0tulipano 3gallina
120             3bietola 3betulla 0narciso 0ontano 3covata
121             3pervinca 0carpino 3spugnola 0faggio 2ape
122             3lattuga 0larice 3cicuta 0ravanello 2arnia
123             2albero_di_Giuda 3lattuga 0ippocastano 3rucola 0piccione
124             0lillà 2anemone 3viola_del_pensiero 0mirtillo 0coltello_da_innesto
125             ),
126             # Floréal https://it.wikipedia.org/wiki/Fiorile
127             qw(
128             3rosa 3quercia 3felce 0biancospino 0usignolo
129             2aquilegia 0mughetto 0fungo 0giacinto 0rastrello
130             0rabarbaro 3lupinella 3violacciocca_gialla 3lonicera 0baco_da_seta
131             3consolida_maggiore 3pimpinella 2alisso_sassicolo 2atriplice 0sarchiello
132             3statice 3fritillaria 3borragine 3valeriana 3carpa
133             3fusaggine 3erba_cipollina 3buglossa 0senape 0vincastro
134             ),
135             # Prairial https://it.wikipedia.org/wiki/Pratile
136             qw(
137             3erba_medica 2emerocallide 0trifoglio 2angelica 2anatra
138             3melissa 2avena_altissima 0giglio_martagone 0timo_serpillo 3falce
139             3fragola 3betonica 0pisello 3acacia 3quaglia
140             0garofano 0sambuco 0papavero 0tiglio 0forcone
141             0fiordaliso 3camomilla 0caprifoglio 0caglio 3tinca
142             0gelsomino 3verbena 0timo 3peonia 0carro
143             ),
144             # Messidor https://it.wikipedia.org/wiki/Messidoro
145             qw(
146             3segale 2avena 3cipolla 3veronica 0mulo
147             0rosmarino 0cetriolo 1scalogno 2assenzio 0falcetto
148             0coriandolo 0carciofo 3violacciocca 3lavanda 0camoscio
149             0tabacco 0ribes 3cicerchia 3ciliegia 2ovile
150             3menta 0cumino 0fagiolo 2alcanna 3faraona
151             3salvia 2aglio 3veccia 0grano 3ciaramella
152             ),
153             # Thermidor https://it.wikipedia.org/wiki/Termidoro
154             qw(
155             1spelto 0tasso_barbasso 0melone 0loglio 2ariete
156             2equiseto 2artemisia 0cartamo 3mora 2annaffiatoio
157             2eringio 3salicornia 2albicocca 0basilico 3pecora
158             2altea 0lino 3mandorla 3genziana 3chiusa
159             3carlina_bianca 0cappero 3lenticchia 2enula 3lontra
160             0mirto 3colza 0lupino 0cotone 0mulino
161             ),
162             # Fructidor https://it.wikipedia.org/wiki/Fruttidoro
163             qw(
164             3prugna 0miglio 3vescia 2orzo_maschio 0salmone
165             3tuberosa 2orzo_comune 2apocino 3liquirizia 3scala
166             3anguria 0finocchio 3crespino 0noce 3trota
167             0limone 0cardo 2alaterno 0garofano_d'India 3gerla
168             3rosa_canina 3nocciola 0luppolo 0sorgo 0gambero
169             2arancio_amaro 3verga_d'oro 0granoturco 3castagna 3cesta
170             ),
171             # Jours complémentaires
172             qw(
173             3virtù 0genio 0lavoro 2opinione 4ricompense
174             3rivoluzione
175             ),
176             );
177             my @prefix = ( 'giorno del '
178             , 'giorno dello '
179             , "giorno dell'"
180             , 'giorno della '
181             , 'giorno delle '
182             );
183              
184             my %event = ();
185              
186             sub new {
187 9     9 1 46 return bless {}, $_[0];
188             }
189              
190             sub month_name {
191 6     6 1 17 my ($self, $date) = @_;
192 6         15 return $months[$date->month_0]
193             }
194              
195             sub month_abbreviation {
196 3     3 1 9 my ($self, $date) = @_;
197 3         8 return $months_short[$date->month_0]
198             }
199              
200             sub day_name {
201 8     8 1 18 my ($self, $date) = @_;
202 8         23 return $decade_days[$date->day_of_decade_0];
203             }
204              
205             sub day_abbreviation {
206 5     5 1 11 my ($self, $date) = @_;
207 5         14 return $decade_days_short[$date->day_of_decade_0];
208             }
209              
210 4 100   4 1 10 sub am_pm { $_[0]->am_pms->[ $_[1]->hour < 5 ? 0 : 1 ] }
211              
212             sub _raw_feast {
213 1     1   2 my ($self, $date) = @_;
214 1         3 $feast[$date->day_of_year_0];
215             }
216              
217             sub feast_short {
218 1     1 1 4 my ($self, $date) = @_;
219 1         3 my $lb = $feast[$date->day_of_year_0];
220 1         4 $lb =~ s/^\?//;
221 1         3 $lb =~ s/_/ /g;
222 1         6 return substr($lb, 1);
223             }
224              
225             sub feast_long {
226 1     1 1 2 my ($self, $date) = @_;
227 1         4 my $lb = $feast[$date->day_of_year_0];
228 1         4 $lb =~ s/^\?//;
229 1         2 $lb =~ s/_/ /g;
230 1         7 $lb =~ s/^(\d)/$prefix[$1]/;
231 1         6 return $lb;
232             }
233              
234             sub feast_caps {
235 4     4 1 9 my ($self, $date) = @_;
236 4         11 my $lb = $feast[$date->day_of_year_0];
237 4         13 $lb =~ s/^\?//;
238 4         10 $lb =~ s/_/ /g;
239 4         30 $lb =~ s/^(\d)(.)/\u$prefix[$1]\u$2/;
240 4         21 return $lb;
241             }
242              
243 4     4 1 24 sub full_date_format { $_[0]->date_formats->{full} }
244 4     4 1 15 sub long_date_format { $_[0]->date_formats->{long} }
245 4     4 1 14 sub medium_date_format { $_[0]->date_formats->{medium} }
246 4     4 1 14 sub short_date_format { $_[0]->date_formats->{short} }
247 4     4 1 15 sub default_date_format { $_[0]->date_formats->{ $_[0]->default_date_format_length } }
248              
249 4     4 1 13 sub full_time_format { $_[0]->time_formats->{full} }
250 4     4 1 19 sub long_time_format { $_[0]->time_formats->{long} }
251 4     4 1 11 sub medium_time_format { $_[0]->time_formats->{medium} }
252 4     4 1 14 sub short_time_format { $_[0]->time_formats->{short} }
253 4     4 1 15 sub default_time_format { $_[0]->time_formats->{ $_[0]->default_time_format_length } }
254              
255 10 100   10   21 sub _datetime_format_pattern_order { $_[0]->date_before_time ? (0, 1) : (1, 0) }
256              
257 2     2 1 10 sub full_datetime_format { join ' ', ( $_[0]-> full_date_format, $_[0]-> full_time_format )[ $_[0]->_datetime_format_pattern_order ] }
258 2     2 1 10 sub long_datetime_format { join ' ', ( $_[0]-> long_date_format, $_[0]-> long_time_format )[ $_[0]->_datetime_format_pattern_order ] }
259 2     2 1 9 sub medium_datetime_format { join ' ', ( $_[0]-> medium_date_format, $_[0]-> medium_time_format )[ $_[0]->_datetime_format_pattern_order ] }
260 2     2 1 10 sub short_datetime_format { join ' ', ( $_[0]-> short_date_format, $_[0]-> short_time_format )[ $_[0]->_datetime_format_pattern_order ] }
261 2     2 1 8 sub default_datetime_format { join ' ', ( $_[0]->default_date_format, $_[0]->default_time_format )[ $_[0]->_datetime_format_pattern_order ] }
262              
263 4     4 1 9 sub default_date_format_length { $default_date_format_length }
264 4     4 1 9 sub default_time_format_length { $default_time_format_length }
265              
266 0     0 1 0 sub month_names { [ @months ] }
267 0     0 1 0 sub month_abbreviations { [ @months_short ] }
268 0     0 1 0 sub day_names { [ @decade_days ] }
269 0     0 1 0 sub day_abbreviations { [ @decade_days_short ] }
270 4     4 0 14 sub am_pms { [ @am_pms ] }
271 20     20 1 57 sub date_formats { \%date_formats }
272 20     20 1 44 sub time_formats { \%time_formats }
273 5     5 0 25 sub date_before_time { $date_before_time }
274 2     2 0 18 sub date_parts_order { $date_parts_order }
275              
276             sub on_date {
277 1     1 1 4 return '';
278             }
279              
280             # A module must return a true value. Traditionally, a module returns 1.
281             # But this module is a revolutionary one, so it discards all old traditions.
282             "Ah ! ça ira ! ça ira !";
283              
284             __END__
285              
286             =encoding utf8
287              
288             =head1 NAME
289              
290             DateTime::Calendar::FrenchRevolutionary::Locale::it -- Italian localization for the French
291             revolutionary calendar.
292              
293             =head1 SYNOPSIS
294              
295             use DateTime::Calendar::FrenchRevolutionary::Locale;
296             my $italian_locale = DateTime::Calendar::FrenchRevolutionary::Locale->load('it');
297              
298             my $italian_month_name =$italian_locale->month_name($date);
299              
300             =head1 DESCRIPTION
301              
302             This module provides localization for DateTime::Calendar::FrenchRevolutionary.
303             Usually, its methods will be invoked only from DT::C::FR.
304              
305             =head1 USAGE
306              
307             This module provides the following class methods:
308              
309             =over 4
310              
311             =item * new
312              
313             Returns an object instance, which is just a convenient value to be
314             stored in a variable.
315              
316             Contrary to the widely used Gregorian calendar, there is no need to
317             customize a French Revolutionary calendar locale. Therefore, there are
318             no instance data and no instance methods.
319              
320             =item * month_name ($date)
321              
322             Returns an Italian translation for C<$date>'s month, where C<$date> is
323             a C<DateTime::Calendar::FrenchRevolutionary> object.
324              
325             =item * month_abbreviation ($date)
326              
327             Returns a 3-letter abbreviation for the Italian month name.
328              
329             =item * day_name ($date)
330              
331             Returns an Italian translation for the day name.
332              
333             =item * day_abbreviation ($date)
334              
335             Returns a 3-letter abbreviation for the Italian day name.
336              
337             =item * am_pm ($date)
338              
339             Returns a code (typically C<AM> or C<PM>) showing whether the datetime
340             is in the morning or the afternoon. Outside the sexagesimal time with
341             a 1..12 hour range, this is not very useful.
342              
343             =item * feast_short ($date)
344              
345             Hopefully returns an adequate italian translation for the plant,
346             animal or tool that correspond to C<$date>'s feast.
347              
348             Note: in some cases, the feast French name is left untranslated, while
349             in some other cases, the translation is inadequate. If you are fluent
350             in both French and Italian, do not hesitate to send corrections to the
351             author.
352              
353             =item * feast_long ($date)
354              
355             Same as C<feast_short>, with a "day" prefix.
356              
357             =item * feast_caps ($date)
358              
359             Same as C<feast_long> with capitalized first letters.
360              
361             =item * on_date ($date)
362              
363             Not implemented for the Italian locale. This method returns an empty string.
364              
365             =item * full_date_format, long_date_format, medium_date_format, short_date_format
366              
367             Class methods, giving four C<strftime> canned formats for dates,
368             without the need to remember all the C<%> specifiers.
369              
370             =item * full_time_format, long_time_format, medium_time_format, short_time_format
371              
372             Same thing, C<strftime> canned formats for decimal time.
373              
374             =item * full_datetime_format, long_datetime_format, medium_datetime_format, short_datetime_format
375              
376             Same thing, for formats including both the date and the decimal time.
377              
378             =item * default_date_format, default_time_format, default_datetime_format
379              
380             Class methods suggesting one each of the date formats, of the time
381             formats and of the datetime formats.
382              
383             =item * full_time_format, long_time_format, medium_time_format, short_time_format
384              
385             Same thing, C<strftime> canned formats for decimal time.
386              
387             =item * full_datetime_format, long_datetime_format, medium_datetime_format, short_datetime_format
388              
389             Same thing, for formats including both the date and the decimal time.
390              
391             =item * default_date_format, default_time_format, default_datetime_format
392              
393             Class methods suggesting one each of the date formats, of the time
394             formats and of the datetime formats.
395              
396             =item * default_date_format_length, default_time_format_length
397              
398             While C<default_date_format> and C<default_time_format> give the
399             actual default formats, with C<%> and all, these class methods give a
400             one-word description of the default formats: C<short>, C<medium>,
401             C<long> or C<full>.
402              
403             =item * date_formats, time_formats
404              
405             These class methods give a hashtable where the key is the length
406             (C<short>, C<medium>, C<long> and C<full>) and the value is the
407             corresponding format, complete with C<%> and specifiers.
408              
409             =item * month_names, month_abbreviations, day_names, day_abbreviations
410              
411             Class methods giving the whole array of month or day names or abbrevs,
412             not limited to the date implemented by the invocant.
413              
414             =back
415              
416             =head1 SUPPORT
417              
418             Support for this module is provided via the datetime@perl.org email
419             list. See L<https://lists.perl.org/> for more details.
420              
421             Please report any bugs or feature requests to Github at
422             L<https://github.com/jforget/DateTime-Calendar-FrenchRevolutionary>,
423             and create an issue or submit a pull request.
424              
425             If you have no feedback after a week or so, try to reach me by email
426             at JFORGET at cpan dot org. The notification from Github may have
427             failed to reach me. In your message, please mention the distribution
428             name in the subject, so my spam filter and I will easily dispatch the
429             email to the proper folder.
430              
431             On the other hand, I may be on vacation or away from Internet for a
432             good reason. Do not be upset if I do not answer immediately. You
433             should write me at a leisurely rythm, about once per month, until I
434             react.
435              
436             If after about six months or a year, there is still no reaction from
437             me, you can worry and start the CPAN procedure for module adoption.
438             See L<https://groups.google.com/g/perl.module-authors/c/IPWjASwuLNs>
439             L<https://www.cpan.org/misc/cpan-faq.html#How_maintain_module>
440             and L<https://www.cpan.org/misc/cpan-faq.html#How_adopt_module>.
441              
442             =head1 AUTHOR
443              
444             Jean Forget <JFORGET@cpan.org>
445              
446             =head1 SEE ALSO
447              
448             =head2 Internet
449              
450             L<http://datetime.perl.org/>
451              
452             L<https://it.wikipedia.org/wiki/Calendario_rivoluzionario_francese>.
453              
454             =head1 LICENSE STUFF
455              
456             Copyright (c) 2021 Jean Forget. All rights reserved. This program is
457             free software. You can distribute, adapt, modify, and otherwise mangle
458             DateTime::Calendar::FrenchRevolutionary under the same terms as perl
459             5.16.3.
460              
461             This program is distributed under the same terms as Perl 5.16.3: GNU
462             Public License version 1 or later and Perl Artistic License
463              
464             You can find the text of the licenses in the F<LICENSE> file or at
465             L<https://dev.perl.org/licenses/artistic.html> and
466             L<https://www.gnu.org/licenses/old-licenses/gpl-1.0.html>.
467              
468             Here is the summary of GPL:
469              
470             This program is free software; you can redistribute it and/or modify
471             it under the terms of the GNU General Public License as published by
472             the Free Software Foundation; either version 1, or (at your option)
473             any later version.
474              
475             This program is distributed in the hope that it will be useful, but
476             WITHOUT ANY WARRANTY; without even the implied warranty of
477             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
478             General Public License for more details.
479              
480             You should have received a copy of the GNU General Public License
481             along with this program; if not, see L<https://www.gnu.org/licenses/>
482             or contact the Free Software Foundation, Inc., L<https://www.fsf.org>.
483              
484             =cut