FrenchRevolutionary.pm

filter: Statementstmt 92.7% 356 / 384 Branchbran 83.7% 77 / 92 Conditioncond 86.9% 40 / 46 MC/DCmcdc 78.2% 18 / 23 Subroutinesub 92.8% 129 / 139 Podpod 82.3% 42 / 51 totaltotal 90.0% 662 / 735 CC 64 SCAR 10.0
CC
64
Cov
91%
_is_leap_year
10.0
_rd2ymd
9.0
strftime
7.0
CRAP 2.7
↑ Summary FrenchRevolutionary/Locale.pm »
1 # -*- encoding: utf-8; indent-tabs-mode: nil -*-
2 #
3 # Perl DateTime extension for converting to/from the French Revolutionary calendar
4 # Copyright (c) 2003, 2004, 2010, 2011, 2012, 2014, 2016, 2019, 2021 Jean Forget. All rights reserved.
5 #
6 # See the license in the embedded documentation below.
7 #
8  
9 package DateTime::Calendar::FrenchRevolutionary;
10  
11 17 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 17 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 17 $VERSION = '0.17';
17  
18 17 ▶use Params::Validate qw(validate SCALAR BOOLEAN OBJECT);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 17 ▶use Roman;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 17 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 17 ▶use DateTime::Calendar::FrenchRevolutionary::Locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 my $BasicValidate =
24 { year => { type => SCALAR },
25 month => { type => SCALAR, default => 1,
26 callbacks =>
27 { 'is between 1 and 13' =>
28 1424 ▶ sub { $_[0] >= 1 && $_[0] <= 13 }
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 1 and $_[0] <= 13 1424 0 1424
29 },
30 },
31 day => { type => SCALAR, default => 1,
32 callbacks =>
33 { 'is between 1 and 30' =>
34 1391 ▶ sub { $_[0] >= 1 && $_[0] <= 30 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 1 and $_[0] <= 30 1391 0 1391
35 },
36 },
37 hour => { type => SCALAR, default => 0,
38 callbacks =>
39 { 'is between 0 and 9' =>
40 1161 ▶ sub { $_[0] >= 0 && $_[0] <= 9 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 0 and $_[0] <= 9 1161 0 1161
41 },
42 },
43 minute => { type => SCALAR, default => 0,
44 callbacks =>
45 { 'is between 0 and 99' =>
46 1161 ▶ sub { $_[0] >= 0 && $_[0] <= 99 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 0 and $_[0] <= 99 1161 0 1161
47 },
48 },
49 second => { type => SCALAR, default => 0,
50 callbacks =>
51 { 'is between 0 and 99' =>
52 1161 ▶ sub { $_[0] >= 0 && $_[0] <= 99 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 0 and $_[0] <= 99 1161 0 1161
53 },
54 },
55 abt_hour => { type => SCALAR, default => 0,
56 callbacks =>
57 { 'is between 0 and 23' =>
58 200 ▶ sub { $_[0] >= 0 && $_[0] <= 23 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 0 and $_[0] <= 23 200 0 200
59 },
60 },
61 abt_minute => { type => SCALAR, default => 0,
62 callbacks =>
63 { 'is between 0 and 59' =>
64 200 ▶ sub { $_[0] >= 0 && $_[0] <= 59 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 0 and $_[0] <= 59 200 0 200
65 },
66 },
67 abt_second => { type => SCALAR, default => 0,
68 callbacks =>
69 { 'is between 0 and 61' =>
70 200 ▶ sub { $_[0] >= 0 && $_[0] <= 61 },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 0 and $_[0] <= 61 200 0 200
71 },
72 },
73 nanosecond => { type => SCALAR, default => 0,
74 callbacks =>
75 { 'cannot be negative' =>
76 222 ▶ sub { $_[0] >= 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
77 }
78 },
79 locale => { type => SCALAR | OBJECT,
80 callbacks =>
81 { "only 'fr', 'en', 'es' and 'it' possible" =>
82 265 ▶ sub { ($_[0] eq 'fr') or ($_[0] eq 'en')
Subroutine __ANON__: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq "fr" or $_[0] eq "en" or $_[0] eq "es" or $_[0] eq "it" or ref($_[0]) =~ /(?:en|es|fr|it)$/ 262 3 265
Condition100%9/9
$_[0] eq "fr" or $_[0] eq "en" or $_[0] eq "es" or $_[0] eq "it"
l!l&&r!l&&!r
245173
$_[0] eq "fr" or $_[0] eq "en" or $_[0] eq "es"
l!l&&r!l&&!r
2281720
$_[0] eq "fr" or $_[0] eq "en"
l!l&&r!l&&!r
2072137
MC/DC100%4/4
$_[0] eq "fr" or $_[0] eq "en" or $_[0] eq "es" or $_[0] eq "it"
$_[0] eq "fr" $_[0] eq "en" $_[0] eq "es" $_[0] eq "it"
Truth table100%5/5
A or B or C or D
A= $_[0] eq "fr"B= $_[0] eq "en"C= $_[0] eq "es"D= $_[0] eq "it"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
83 or ($_[0] eq 'es')
84 or ($_[0] eq 'it')
85 or ref($_[0]) =~ /(?:en|es|fr|it)$/ },
86 },
87 17 default => DefaultLocale() },
88 };
89  
90 my $NewValidate =
91 { %$BasicValidate,
92 time_zone => { type => SCALAR | OBJECT,
93 callbacks =>
94 { "only 'floating' possible" =>
95 161 ▶ sub { ($_[0] eq 'floating') or ref($_[0]) and $_[0]->is_floating },
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq "floating" or ref $_[0] and $_[0]->is_floating 158 3 161
Condition100%6/6
$_[0] eq 'floating' || ref $_[0] && $_[0]->is_floating
l!l&&r!l&&!r
15812
ref $_[0] and $_[0]->is_floating
!ll&&!rl&&r
111
MC/DC100%3/3
$_[0] eq 'floating' || ref $_[0] && $_[0]->is_floating
$_[0] eq 'floating' ref $_[0] $_[0]->is_floating
Truth table100%4/4
A || B and C
A= $_[0] eq 'floating'B= ref $_[0]C= $_[0]->is_floating
ABCresult
1XX1
0111
00X0
0100
96 },
97 17 default => 'floating' },
98 };
99 17 my $Lastday_validate = { %$BasicValidate };
100 17 delete $Lastday_validate->{day};
101  
102 # Constructors
103 1393 ▶sub new {
Subroutine new: called CC=6 SCAR=18.2
Pod documented
104 1393 my $class = shift;
105 1393 my %args = validate( @_, $NewValidate );
106  
107 1390 my $self = {};
108  
109 1390 $self->{tz} = DateTime::TimeZone->new(name => 'floating');
110 1390 ▶ if ( ref $args{locale} )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args{'locale'}) { } 2 1388 1390
111 2 { $self->{locale} = $args{locale} }
112 else
113 1388 { $self->{locale} = DateTime::Calendar::FrenchRevolutionary::Locale->load( $args{locale} ) }
114  
115 1390 $self->{local_rd_days} = $class->_ymd2rd(@args{qw(year month day)});
116 1390 my $abtsecs = $class->_time_as_abt_seconds(@args{qw(abt_hour abt_minute abt_second)});
117 1390 my $decsecs = $class->_time_as_seconds(@args{qw(hour minute second)});
118 1390 ▶ warn("You cannot specify both 24x60x60 time and 10x100x100 time when initializing a date")
Branch: 1 branch
BranchTrueFalseTotal
if $^W and $abtsecs and $decsecs 0 1390 1390
Condition33%2/6
$^W and $abtsecs and $decsecs
!ll&&!rl&&r
139000
$^W and $abtsecs
!ll&&!rl&&r
139000
MC/DC0%0/3
$^W and $abtsecs and $decsecs
$^W $abtsecs $decsecs
Truth table25%1/4
A and B and C
A= $^WB= $abtsecsC= $decsecs
ABCresult
0XX0
10X0
1100
1111
119 if $^W && $abtsecs && $decsecs;
120 # We prefer decimal time over Anglo-Babylonian time when initializing a date
121 1390 ▶ $self->{local_rd_secs} = $decsecs ? $decsecs : $abtsecs;
Branch: 1 branch
BranchTrueFalseTotal
$decsecs ? : 1070 320 1390
122 1390 $self->{rd_nano} = $args{nanosecond};
123  
124 1390 bless $self, $class;
125 1390 $self->_calc_local_components;
126 1390 $self->_calc_utc_rd;
127  
128 1390 return $self;
129 }
130  
131 3 ▶sub from_epoch {
Subroutine from_epoch: called CC=1 SCAR=0.0
Pod documented
132 3 my $class = shift;
133 3 my %args = validate( @_,
134 { epoch => { type => SCALAR },
135 locale => { type => SCALAR | OBJECT,
136 default => $class->DefaultLocale },
137  
138 }
139 );
140  
141 3 my $date = DateTime->from_epoch(%args);
142 3 return $class->from_object(object => $date);
143 }
144  
145 # use scalar time in case someone's loaded Time::Piece
146 1 ▶sub now { shift->from_epoch(epoch => (scalar time), @_) }
Subroutine now: called CC=1 SCAR=0.0
Pod documented
147  
148 157 ▶sub from_object {
Subroutine from_object: called CC=3 SCAR=11.0
Pod documented
149 157 my $class = shift;
150 157 my %args = validate(@_,
151 { object => { type => OBJECT,
152 can => 'utc_rd_values',
153 },
154 locale => { type => SCALAR | OBJECT,
155 default => $class->DefaultLocale },
156 },
157 );
158  
159 157 my $object = delete $args{object};
160 157 ▶ $object = $object->clone->set_time_zone('floating')
Branch: 1 branch
BranchTrueFalseTotal
if $object->can("set_time_zone") 157 0 157
161 if $object->can('set_time_zone');
162  
163 157 my ($rd_days, $rd_secs, $rd_nano) = $object->utc_rd_values;
164  
165 157 my %p;
166 157 @p{ qw(year month day) } = $class->_rd2ymd($rd_days);
167 # ABT seconds preferred over decimal seconds, because of precision loss
168 157 @p{ qw(abt_hour abt_minute abt_second) } = $class->_abt_seconds_as_components($rd_secs);
169 # nanoseconds are copied, never converted ABT to decimal or reverse
170 157 ▶ $p{nanosecond} = $rd_nano || 0;
Condition100%2/2
$rd_nano || 0
l!l
1156
MC/DC100%1/1
$rd_nano || 0
$rd_nano
Truth table100%2/2
A
A= $rd_nano
Aresult
11
00
171 #@p{ qw(hour minute second) } = $class->_seconds_as_components($rd_secs);
172  
173 157 my $new = $class->new(%p, %args, time_zone => 'floating');
174  
175 157 return $new;
176 }
177  
178 33 ▶sub last_day_of_month {
Subroutine last_day_of_month: called CC=3 SCAR=11.0
Pod documented
179 33 my $class = shift;
180 33 my %p = validate( @_, $Lastday_validate);
181 33 ▶ my $day = $p{month} <= 12 ? 30 : $class->_is_leap_year($p{year}) ? 6 : 5;
Branch: 2 branches
BranchTrueFalseTotal
$p{'month'} <= 12 ? : 10 23 33
$class->_is_leap_year($p{'year'}) ? : 7 16 23
182 33 return $class->new(%p, day => $day);
183 }
184  
185 1 ▶sub clone { bless { %{ $_[0] } }, ref $_[0] }
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
186  
187 # Many of the same parameters as new() but all of them are optional,
188 # and there are no defaults.
189 my $SetValidate =
190 17 { map { my %copy = %{ $BasicValidate->{$_} };
191 187 delete $copy{default};
192 187 $copy{optional} = 1;
193 187 $_ => \%copy }
194 keys %$BasicValidate };
195 sub set
196 32 ▶{
Subroutine set: called CC=1 SCAR=0.0
Pod documented
197 32 my $self = shift;
198 32 my %p = validate( @_, $SetValidate );
199  
200 my %old_p =
201 32 ( map { $_ => $self->$_() }
202 qw( year month day hour minute second nanosecond locale )
203 );
204  
205 32 my $new_dt = (ref $self)->new( %old_p, %p );
206  
207 32 %$self = %$new_dt;
208  
209 32 return $self;
210 }
211  
212 1 ▶sub set_time_zone { } # do nothing, only 'floating' allowed
Subroutine set_time_zone: called CC=1 SCAR=0.0
Pod undocumented
213  
214 # Internal functions
215 17 ▶use constant REV_BEGINNING => 654415; # RD value for 1 Vendémiaire I in the Revolutionary calendar
Subroutine BEGIN: called CC=1 SCAR=0.0
216 17 ▶use constant NORMAL_YEAR => 365;
Subroutine BEGIN: called CC=1 SCAR=0.0
217 17 ▶use constant LEAP_YEAR => 366;
Subroutine BEGIN: called CC=1 SCAR=0.0
218 17 ▶use constant FOUR_YEARS => 4 * NORMAL_YEAR + 1; # one leap year every four years
Subroutine BEGIN: called CC=1 SCAR=0.0
219 17 ▶use constant CENTURY => 25 * FOUR_YEARS - 1; # centuries aren't leap years...
Subroutine BEGIN: called CC=1 SCAR=0.0
220 17 ▶use constant FOUR_CENTURIES => 4 * CENTURY + 1; # ...except every four centuries that are.
Subroutine BEGIN: called CC=1 SCAR=0.0
221 17 ▶use constant FOUR_MILLENIA => 10 * FOUR_CENTURIES - 1; # ...except every four millenia that are not.
Subroutine BEGIN: called CC=1 SCAR=0.0
222  
223 # number of days between the start of the revolutionary calendar, and the
224 # beginning of year n - 1 as long as the equinox rule is in effect
225 17 my @YEARS_BEGINS= (0, 365, 730, 1096, 1461, 1826, 2191, 2557, 2922, 3287, 3652,
226 4018, 4383, 4748, 5113, 5479, 5844);
227 69 ▶sub _is_leap_year {
Subroutine _is_leap_year: called CC=10 SCAR=23.0
228 69 my ($self, $year) = @_;
229  
230 # Autumn equinox from I to XIX
231 69 ▶ return 1 if ($year == 3) or ($year == 7) or ($year == 11) or ($year == 15);
Branch: 1 branch
BranchTrueFalseTotal
if $year == 3 or $year == 7 or $year == 11 or $year == 15 8 61 69
Condition100%9/9
$year == 3 or $year == 7 or $year == 11 or $year == 15
l!l&&r!l&&!r
6261
$year == 3 or $year == 7 or $year == 11
l!l&&r!l&&!r
4263
$year == 3 or $year == 7
l!l&&r!l&&!r
2265
MC/DC100%4/4
$year == 3 or $year == 7 or $year == 11 or $year == 15
$year == 3 $year == 7 $year == 11 $year == 15
Truth table100%5/5
A or B or C or D
A= $year == 3B= $year == 7C= $year == 11D= $year == 15
ABCDresult
1XXX1
01XX1
001X1
00011
00000
232 61 ▶ return 0 if ($year < 20);
Branch: 1 branch
BranchTrueFalseTotal
if $year < 20 20 41 61
233  
234 # Romme rule from XX on
235 41 ▶ return 0 if $year % 4; # not a multiple of 4 -> normal year
Branch: 1 branch
BranchTrueFalseTotal
if $year % 4 15 26 41
236 26 ▶ return 1 if $year % 100; # a multiple of 4 but not of 100 is a leap year
Branch: 1 branch
BranchTrueFalseTotal
if $year % 100 5 21 26
237 21 ▶ return 0 if $year % 400; # a multiple of 100 but not of 400 is a normal year
Branch: 1 branch
BranchTrueFalseTotal
if $year % 400 13 8 21
238 8 ▶ return 1 if $year % 4000; # a multiple of 400 but not of 4000 is leap
Branch: 1 branch
BranchTrueFalseTotal
if $year % 4000 5 3 8
239 3 return 0; # a multiple of 4000 is a normal year
240 }
241  
242 1390 ▶sub _calc_utc_rd {
Subroutine _calc_utc_rd: called CC=2 SCAR=7.8
243 1390 my $self = shift;
244  
245 1390 delete $self->{utc_c};
246  
247 1390 ▶ if ($self->{tz}->is_utc)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"tz"}->is_utc) 0 1390 1390
248 {
249 0 $self->{utc_rd_days} = $self->{local_rd_days};
250 0 $self->{utc_rd_secs} = $self->{local_rd_secs};
251 0 return;
252 }
253  
254 1390 $self->{utc_rd_days} = $self->{local_rd_days};
255 1390 $self->{utc_rd_secs} = $self->{local_rd_secs} - $self->_offset_from_local_time;
256 1390 _normalize_seconds($self->{utc_rd_days}, $self->{utc_rd_secs}, $self->{rd_nano});
257 }
258  
259 0 ▶sub _calc_local_rd {
Subroutine _calc_local_rd: not called CC=2 SCAR=17.9
260 0 my $self = shift;
261  
262 0 delete $self->{local_c};
263  
264 # We must short circuit for UTC times or else we could end up with
265 # loops between DateTime.pm and DateTime::TimeZone
266 0 ▶ if ($self->{tz}->is_utc)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'tz'}->is_utc) { } 0 0 0
267 {
268 0 $self->{local_rd_days} = $self->{utc_rd_days};
269 0 $self->{local_rd_secs} = $self->{utc_rd_secs};
270 }
271 else
272 {
273 0 $self->{local_rd_days} = $self->{utc_rd_days};
274 0 $self->{local_rd_secs} = $self->{utc_rd_secs} + $self->offset;
275 0 _normalize_seconds($self->{local_rd_days}, $self->{local_rd_secs});
276 }
277  
278 0 $self->_calc_local_components;
279 }
280  
281 1390 ▶sub _normalize_seconds {
Subroutine _normalize_seconds: called CC=2 SCAR=7.1
282 1390 my ($d, $s) = @_;
283 1390 my $adj;
284 1390 ▶ if ($s < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($s < 0) { } 0 1390 1390
285 0 { $adj = int(($s - 86399) / 86400) }
286 else
287 1390 { $adj = int($s / 86400) }
288 1390 $_[0] += $adj;
289 1390 $_[1] -= $adj * 86400;
290 }
291  
292 1390 ▶sub _calc_local_components {
Subroutine _calc_local_components: called CC=1 SCAR=0.0
293 1390 my $self = shift;
294 1390 @{ $self->{local_c} }{ qw(year month day day_of_decade day_of_year) }
295 1390 = $self->_rd2ymd($self->{local_rd_days}, 1);
296 1390 @{ $self->{local_c} }{ qw(abt_hour abt_minute abt_second) }
297 1390 = $self->_abt_seconds_as_components($self->{local_rd_secs});
298 1390 @{ $self->{local_c} }{ qw(hour minute second) }
299 1390 = $self->_seconds_as_components($self->{local_rd_secs});
300 }
301  
302 0 ▶sub _calc_utc_components {
Subroutine _calc_utc_components: not called CC=1 SCAR=6.9
303 0 my $self = shift;
304 0 @{ $self->{utc_c} }{ qw(year month day) } = $self->_rd2ymd($self->{utc_rd_days});
305 0 @{ $self->{utc_c} }{ qw(abt_hour abt_minute abt_second) }
306 0 = $self->_abt_seconds_as_components($self->{utc_rd_secs});
307 0 @{ $self->{utc_c} }{ qw(hour minute second) }
308 0 = $self->_seconds_as_components($self->{utc_rd_secs});
309 }
310  
311 1390 ▶sub _ymd2rd {
Subroutine _ymd2rd: called CC=4 SCAR=13.9
312 1390 my ($self, $y, $m, $d) = @_;
313 1390 my $rd = REV_BEGINNING - 1; # minus 1 for the zeroth Vendémiaire
314 1390 $y --; #get years *before* this year. Makes math easier. :)
315 # first, convert year into days. . .
316 1390 ▶ if ($y < 0 || $y >= 16) {
Branch: 1 branch
BranchTrueFalseTotal
if ($y < 0 or $y >= 16) { } 243 1147 1390
Condition100%3/3
$y < 0 or $y >= 16
l!l&&r!l&&!r
32401147
MC/DC100%2/2
$y < 0 or $y >= 16
$y < 0 $y >= 16
Truth table100%3/3
A or B
A= $y < 0B= $y >= 16
ABresult
1X1
011
000
317 # Romme rule in effect, or nearly so
318 243 my $x = int($y/4000);
319 243 ▶ --$x if $y <= 0;
Branch: 1 branch
BranchTrueFalseTotal
if $y <= 0 3 240 243
320 243 $rd += $x * FOUR_MILLENIA;
321 243 $y %= 4000;
322 243 $rd += int($y/400)* FOUR_CENTURIES;
323 243 $y %= 400;
324 243 $rd += int($y/100)* CENTURY;
325 243 $y %= 100;
326 243 $rd += int($y/4)* FOUR_YEARS;
327 243 $y %= 4;
328 243 $rd += $y * NORMAL_YEAR;
329 }
330 else {
331 # table look-up for the programmer-hostile equinox rule
332 1147 $rd += $YEARS_BEGINS[$y];
333 }
334  
335 # now, month into days.
336 1390 $rd += 30 * ($m - 1) + $d;
337 1390 return $rd;
338 }
339  
340 1547 ▶sub _rd2ymd {
Subroutine _rd2ymd: called CC=9 SCAR=22.0
341 1547 my ($self, $rd, $extra) = @_;
342  
343 1547 my $doy;
344 my $y;
345 # note: years and days are initially days *before* today, rather than
346 # today's date. This is because of fenceposts. :)
347 1547 $doy = $rd - REV_BEGINNING;
348 1547 ▶ if ($doy >= 0 && $doy < $YEARS_BEGINS[16]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($doy >= 0 and $doy < $YEARS_BEGINS[16]) { } 1210 337 1547
Condition100%3/3
$doy >= 0 and $doy < $YEARS_BEGINS[16]
!ll&&!rl&&r
63311210
MC/DC100%2/2
$doy >= 0 and $doy < $YEARS_BEGINS[16]
$doy >= 0 $doy < $YEARS_BEGINS[16]
Truth table100%3/3
A and B
A= $doy >= 0B= $doy < $YEARS_BEGINS[16]
ABresult
0X0
100
111
349 1210 $y = scalar grep { $_ <= $doy } @YEARS_BEGINS;
350 1210 $doy -= $YEARS_BEGINS[$y - 1];
351 1210 $doy++;
352 }
353 else {
354 #$doy --;
355 337 my $x;
356 337 $x = int ($doy / FOUR_MILLENIA);
357 337 ▶ --$x if $doy < 0; # So pre-1792 dates will give something that look about right
Branch: 1 branch
BranchTrueFalseTotal
if $doy < 0 6 331 337
358 337 $y += $x * 4000;
359 337 $doy -= $x * FOUR_MILLENIA;
360  
361 337 $x = int ($doy / FOUR_CENTURIES);
362 337 $y += $x * 400;
363 337 $doy -= $x * FOUR_CENTURIES;
364  
365 337 $x = int ($doy / CENTURY);
366 337 ▶ $x = 3 if $x == 4; # last day of the 400-year period; see comment below
Branch: 1 branch
BranchTrueFalseTotal
if $x == 4 4 333 337
367 337 $y += $x * 100;
368 337 $doy -= $x * CENTURY;
369  
370 337 $x = int ($doy / FOUR_YEARS);
371 337 $y += $x * 4;
372 337 $doy -= $x * FOUR_YEARS;
373  
374 337 $x = int ($doy / NORMAL_YEAR);
375 # The integer division above divides the 4-year period, 1461 days,
376 # into 5 parts: 365, 365, 365, 365 and 1. This mathematically sound operation
377 # is wrong with respect to the calendar, which needs to divide
378 # into 4 parts: 365, 365, 365 and 366. Therefore the adjustment below.
379 337 ▶ $x = 3 if $x == 4; # last day of the 4-year period
Branch: 1 branch
BranchTrueFalseTotal
if $x == 4 20 317 337
380 337 $y += $x;
381 337 $doy -= $x * NORMAL_YEAR;
382  
383 337 ++$y; # because of 0-based mathematics vs 1-based chronology
384 337 ++$doy;
385 }
386 1547 ▶ my $d = $doy % 30 || 30;
Condition100%2/2
$doy % 30 || 30
l!l
153710
MC/DC100%1/1
$doy % 30 || 30
$doy % 30
Truth table100%2/2
A
A= $doy % 30
Aresult
11
00
387 1547 my $m = ($doy - $d) / 30 + 1;
388 1547 ▶ if ($extra)
Branch: 1 branch
BranchTrueFalseTotal
if ($extra) 1390 157 1547
389 {
390 # day_of_decade, day_of_year
391 1390 ▶ my $dod = ($d % 10) || 10;
Condition100%2/2
$d % 10 || 10
l!l
136525
MC/DC100%1/1
$d % 10 || 10
$d % 10
Truth table100%2/2
A
A= $d % 10
Aresult
11
00
392 1390 return $y, $m, $d, $dod, $doy;
393 }
394 157 return $y, $m, $d;
395 }
396  
397 # Aliases provided for compatibility with DateTime; if DateTime switches
398 # over to _ymd2rd and _rd2ymd, these will be removed eventually.
399 17 *_greg2rd = \&_ymd2rd;
400 17 *_rd2greg = \&_rd2ymd;
401  
402 #
403 # Accessors
404 #
405 1314 ▶sub year { $_[0]->{local_c}{year} }
Subroutine year: called CC=1 SCAR=0.0
Pod documented
406  
407 91 ▶sub month { $_[0]->{local_c}{month} }
Subroutine month: called CC=1 SCAR=0.0
Pod documented
408 17 *mon = \&month;
409  
410 139 ▶sub month_0 { $_[0]->{local_c}{month} - 1 };
Subroutine month_0: called CC=1 SCAR=0.0
Pod documented
411 17 *mon_0 = \&month_0;
412  
413 117 ▶sub month_name {
Subroutine month_name: called CC=1 SCAR=0.0
Pod documented
414 117 my $self = shift;
415 117 return $self->{locale}->month_name($self);
416 #return $months[$self->month_0]
417 }
418  
419 18 ▶sub month_abbr {
Subroutine month_abbr: called CC=1 SCAR=0.0
Pod documented
420 18 my $self = shift;
421 18 return $self->{locale}->month_abbreviation($self);
422 #return $months_short[$self->month_0]
423 }
424  
425 217 ▶sub day_of_month { $_[0]->{local_c}{day} }
Subroutine day_of_month: called CC=1 SCAR=0.0
Pod documented
426 17 *day = \&day_of_month;
427 17 *mday = \&day_of_month;
428  
429 12 ▶sub day_of_month_0 { $_[0]->{local_c}{day} - 1 }
Subroutine day_of_month_0: called CC=1 SCAR=0.0
Pod undocumented
430 17 *day_0 = \&day_of_month_0;
431 17 *mday_0 = \&day_of_month_0;
432  
433 31 ▶sub day_of_decade { $_[0]->{local_c}{day} % 10 || 10 }
Subroutine day_of_decade: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"local_c"}{"day"} % 10 or 10 30 1 31
434 17 *dod = \&day_of_decade;
435 17 *dow = \&day_of_decade;
436 17 *wday = \&day_of_decade;
437 17 *day_of_week = \&day_of_decade;
438  
439 92 ▶sub day_of_decade_0 { ($_[0]->{local_c}{day} - 1) % 10 }
Subroutine day_of_decade_0: called CC=1 SCAR=0.0
Pod undocumented
440 17 *dod_0 = \&day_of_decade_0;
441 17 *dow_0 = \&day_of_decade_0;
442 17 *wday_0 = \&day_of_decade_0;
443 17 *day_of_week_0 = \&day_of_decade_0;
444  
445 48 ▶sub day_name {
Subroutine day_name: called CC=1 SCAR=0.0
Pod documented
446 48 my $self = shift;
447 48 return $self->{locale}->day_name($self);
448 #return $decade_days[$self->day_of_decade_0];
449 }
450  
451 24 ▶sub day_abbr {
Subroutine day_abbr: called CC=1 SCAR=0.0
Pod documented
452 24 my $self = shift;
453 24 return $self->{locale}->day_abbreviation($self);
454 #return $decade_days_short[$self->day_of_decade_0];
455 }
456  
457 14 ▶sub day_of_year { $_[0]->{local_c}{day_of_year} }
Subroutine day_of_year: called CC=1 SCAR=0.0
Pod documented
458 17 *doy = \&day_of_year;
459  
460 81 ▶sub day_of_year_0 { $_[0]->{local_c}{day_of_year} - 1 }
Subroutine day_of_year_0: called CC=1 SCAR=0.0
Pod undocumented
461 17 *doy_0 = \&day_of_year_0;
462  
463 8 ▶sub feast_short {
Subroutine feast_short: called CC=1 SCAR=0.0
Pod documented
464 8 my ($dt) = @_;
465 8 return $dt->{locale}->feast_short($dt);
466 }
467 17 *feast = \&feast_short;
468  
469 4 ▶sub _raw_feast {
Subroutine _raw_feast: called CC=1 SCAR=0.0
470 4 my ($dt) = @_;
471 4 return $dt->{locale}->_raw_feast($dt);
472 }
473  
474 17 ▶sub feast_long {
Subroutine feast_long: called CC=1 SCAR=0.0
Pod documented
475 17 my ($dt) = @_;
476 17 return $dt->{locale}->feast_long($dt);
477 }
478  
479 44 ▶sub feast_caps {
Subroutine feast_caps: called CC=1 SCAR=0.0
Pod documented
480 44 my ($dt) = @_;
481 44 return $dt->{locale}->feast_caps($dt);
482 }
483  
484 1035 ▶sub ymd {
Subroutine ymd: called CC=2 SCAR=6.9
Pod documented
485 1035 my ($self, $sep) = @_;
486 1035 ▶ $sep = '-' unless defined $sep;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sep 1031 4 1035
487 return sprintf("%0.4d%s%0.2d%s%0.2d",
488 $self->year, $sep,
489 $self->{local_c}{month}, $sep,
490 1035 $self->{local_c}{day});
491 }
492 17 *date = \&ymd;
493  
494 6 ▶sub mdy {
Subroutine mdy: called CC=2 SCAR=6.9
Pod documented
495 6 my ($self, $sep) = @_;
496 6 ▶ $sep = '-' unless defined $sep;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sep 5 1 6
497 return sprintf("%0.2d%s%0.2d%s%0.4d",
498 $self->{local_c}{month}, $sep,
499 6 $self->{local_c}{day}, $sep,
500 $self->year);
501 }
502  
503 6 ▶sub dmy {
Subroutine dmy: called CC=2 SCAR=6.9
Pod documented
504 6 my ($self, $sep) = @_;
505 6 ▶ $sep = '-' unless defined $sep;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sep 5 1 6
506 return sprintf("%0.2d%s%0.2d%s%0.4d",
507 $self->{local_c}{day}, $sep,
508 6 $self->{local_c}{month}, $sep,
509 $self->year);
510 }
511  
512 # Anglo-Babylonian (or sexagesimal) time
513 4 ▶sub abt_hour { $_[0]->{local_c}{abt_hour} }
Subroutine abt_hour: called CC=1 SCAR=0.0
Pod documented
514 4 ▶sub abt_minute { $_[0]->{local_c}{abt_minute} } *abt_min = \&abt_minute;
Subroutine abt_minute: called CC=1 SCAR=0.0
Pod documented
515 4 ▶sub abt_second { $_[0]->{local_c}{abt_second} } *abt_sec = \&abt_second;
Subroutine abt_second: called CC=1 SCAR=0.0
Pod documented
516 9 ▶sub abt_hms {
Subroutine abt_hms: called CC=2 SCAR=6.9
Pod documented
517 9 my ($self, $sep) = @_;
518 9 ▶ $sep = ':' unless defined $sep;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sep 4 5 9
519 return sprintf("%0.2d%s%0.2d%s%0.2d",
520 $self->{local_c}{abt_hour}, $sep,
521 $self->{local_c}{abt_minute}, $sep,
522 9 $self->{local_c}{abt_second});
523 }
524  
525 32 ▶sub nanosecond { $_[0]->{rd_nano} }
Subroutine nanosecond: called CC=1 SCAR=0.0
Pod undocumented
526  
527 # Decimal time
528 97 ▶sub hour { $_[0]->{local_c}{hour} }
Subroutine hour: called CC=1 SCAR=0.0
Pod documented
529 67 ▶sub minute { $_[0]->{local_c}{minute} } *min = \&minute;
Subroutine minute: called CC=1 SCAR=0.0
Pod documented
530 68 ▶sub second { $_[0]->{local_c}{second} } *sec = \&second;
Subroutine second: called CC=1 SCAR=0.0
Pod documented
531  
532 1031 ▶sub hms {
Subroutine hms: called CC=2 SCAR=6.9
Pod documented
533 1031 my ($self, $sep) = @_;
534 1031 ▶ $sep = ':' unless defined $sep;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sep 4 1027 1031
535 return sprintf("%0.1d%s%0.2d%s%0.2d",
536 $self->{local_c}{hour}, $sep,
537 $self->{local_c}{minute}, $sep,
538 1031 $self->{local_c}{second} );
539 }
540 # don't want to override CORE::time()
541 17 *DateTime::Calendar::FrenchRevolutionary::time = \&hms;
542  
543 1027 ▶sub iso8601 {
Subroutine iso8601: called CC=1 SCAR=0.0
Pod documented
544 1027 my $self = shift;
545 1027 return join 'T', $self->ymd, $self->hms(':');
546 }
547 17 *datetime = \&iso8601;
548  
549 46 ▶sub is_leap_year { $_[0]->_is_leap_year($_[0]->year) }
Subroutine is_leap_year: called CC=1 SCAR=0.0
Pod documented
550  
551 21 ▶sub decade_number {
Subroutine decade_number: called CC=1 SCAR=0.0
Pod documented
552 21 my $self = shift;
553 21 return 3 * $self->month + int(($self->day - 1) / 10) - 2;
554 }
555 17 *week_number = \&decade_number;
556  
557 1 ▶sub decade {
Subroutine decade: called CC=1 SCAR=0.0
Pod documented
558 1 my $self = shift;
559 1 return ($self->year, $self->decade_number);
560 }
561 17 *week = \&decade;
562  
563 #sub time_zone { $_[0]->{tz} }
564  
565 4 ▶sub offset { $_[0]->{tz}->offset_for_datetime($_[0]) }
Subroutine offset: called CC=1 SCAR=0.0
Pod undocumented
566 1390 ▶sub _offset_from_local_time { $_[0]->{tz}->offset_for_local_datetime($_[0]) }
Subroutine _offset_from_local_time: called CC=1 SCAR=0.0
567  
568 #sub is_dst { $_[0]->{tz}->is_dst_for_datetime($_[0]) }
569  
570 #sub time_zone_short_name { $_[0]->{tz}->short_name_for_datetime($_[0]) }
571  
572 32 ▶sub locale { $_[0]->{locale} }
Subroutine locale: called CC=1 SCAR=0.0
Pod documented
573  
574 101 ▶sub utc_rd_values { @{ $_[0] }{ 'utc_rd_days', 'utc_rd_secs', 'rd_nano' } }
Subroutine utc_rd_values: called CC=1 SCAR=0.0
Pod documented
575  
576 # Anglo-Babylonian time
577 0 ▶sub utc_rd_as_abt_seconds { ($_[0]->{utc_rd_days} * 86400) + $_[0]->{utc_rd_secs} }
Subroutine utc_rd_as_abt_seconds: not called CC=1 SCAR=6.9
Pod undocumented
578 0 ▶sub local_rd_as_abt_seconds { ($_[0]->{local_rd_days} * 86400) + $_[0]->{local_rd_secs} }
Subroutine local_rd_as_abt_seconds: not called CC=1 SCAR=6.9
Pod undocumented
579 1390 ▶sub _time_as_abt_seconds { $_[1] * 3600 + $_[2] * 60 + $_[3] }
Subroutine _time_as_abt_seconds: called CC=1 SCAR=0.0
580 1547 ▶sub _abt_seconds_as_components { int($_[1] / 3600), int($_[1] % 3600 / 60), $_[1] % 60 }
Subroutine _abt_seconds_as_components: called CC=1 SCAR=0.0
581  
582 # Decimal time
583 1390 ▶sub _time_as_seconds { .864 * ($_[1] * 10000 + $_[2] * 100 + $_[3]) }
Subroutine _time_as_seconds: called CC=1 SCAR=0.0
584 1390 ▶sub _seconds_as_components {
Subroutine _seconds_as_components: called CC=1 SCAR=0.0
585 1390 my $sec = int(.5 + $_[1] / .864);
586 1390 int($sec / 10000), int($sec % 10000 / 100), $sec % 100
587 }
588  
589 # RD 1 is JD 1,721,424.5 - a simple offset
590 2 ▶sub jd {
Subroutine jd: called CC=1 SCAR=0.0
Pod documented
591 2 my $self = shift;
592 2 my $jd = $self->{utc_rd_days} + 1_721_424.5;
593 2 return $jd + ($self->{utc_rd_secs} / 86400);
594 }
595  
596 1 ▶sub mjd { $_[0]->jd - 2_400_000.5 }
Subroutine mjd: called CC=1 SCAR=0.0
Pod documented
597  
598 my %formats = (
599 20 ▶ 'a' => sub { $_[0]->day_abbr }
Subroutine __ANON__: called CC=1 SCAR=0.0
600 39 ▶ , 'A' => sub { $_[0]->day_name }
Subroutine __ANON__: called CC=1 SCAR=0.0
601 13 ▶ , 'b' => sub { $_[0]->month_abbr }
Subroutine __ANON__: called CC=1 SCAR=0.0
602 107 ▶ , 'B' => sub { $_[0]->month_name }
Subroutine __ANON__: called CC=1 SCAR=0.0
603 0 ▶ , 'c' => sub { $_[0]->strftime( $_[0]->{locale}->default_datetime_format ) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
604 4 ▶ , 'C' => sub { int($_[0]->year / 100) }
Subroutine __ANON__: called CC=1 SCAR=0.0
605 52 ▶ , 'd' => sub { sprintf '%02d', $_[0]->day_of_month }
Subroutine __ANON__: called CC=1 SCAR=0.0
606 4 ▶ , 'D' => sub { $_[0]->strftime('%m/%d/%y') }
Subroutine __ANON__: called CC=1 SCAR=0.0
607 86 ▶ , 'e' => sub { sprintf('%2d', $_[0]->day_of_month) }
Subroutine __ANON__: called CC=1 SCAR=0.0
608 1 ▶ , 'f' => sub { sprintf('%2d', $_[0]->month) }
Subroutine __ANON__: called CC=1 SCAR=0.0
609 4 ▶ , 'F' => sub { $_[0]->ymd('-') }
Subroutine __ANON__: called CC=1 SCAR=0.0
610 4 ▶ , 'g' => sub { substr($_[0]->year, -2) }
Subroutine __ANON__: called CC=1 SCAR=0.0
611 5 ▶ , 'G' => sub { sprintf '%04d', $_[0]->year }
Subroutine __ANON__: called CC=1 SCAR=0.0
612 0 ▶ , 'h' => sub { $_[0]->month_abbr }
Subroutine __ANON__: not called CC=1 SCAR=6.9
613 21 ▶ , 'H' => sub { sprintf('%d', $_[0]->hour) }
Subroutine __ANON__: called CC=1 SCAR=0.0
614 13 ▶ , 'I' => sub { my $h = $_[0]->hour || 10; sprintf('%d', $h) }
Subroutine __ANON__: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->hour || 10
l!l
130
MC/DC0%0/1
$_[0]->hour || 10
$_[0]->hour
Truth table50%1/2
A
A= $_[0]->hour
Aresult
11
00
615 5 ▶ , 'j' => sub { sprintf '%03d', $_[0]->day_of_year }
Subroutine __ANON__: called CC=1 SCAR=0.0
616 4 ▶ , 'k' => sub { sprintf('%2d', $_[0]->hour) }
Subroutine __ANON__: called CC=1 SCAR=0.0
617 4 ▶ , 'l' => sub { my $h = $_[0]->hour || 10; sprintf('%2d', $h) }
Subroutine __ANON__: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->hour || 10
l!l
40
MC/DC0%0/1
$_[0]->hour || 10
$_[0]->hour
Truth table50%1/2
A
A= $_[0]->hour
Aresult
11
00
618 1 ▶ , 'L' => sub { sprintf '%04d', $_[0]->year }
Subroutine __ANON__: called CC=1 SCAR=0.0
619 22 ▶ , 'm' => sub { sprintf '%02d', $_[0]->month }
Subroutine __ANON__: called CC=1 SCAR=0.0
620 30 ▶ , 'M' => sub { sprintf '%02d', $_[0]->minute }
Subroutine __ANON__: called CC=1 SCAR=0.0
621 0 ▶ , 'n' => sub { "\n" } # should this be OS-sensitive?
Subroutine __ANON__: not called CC=1 SCAR=6.9
622 14 ▶ , 'p' => sub { $_[0]->{locale}->am_pm($_[0]) }
Subroutine __ANON__: called CC=1 SCAR=0.0
623 4 ▶ , 'P' => sub { lc $_[0]->{locale}->am_pm($_[0]) }
Subroutine __ANON__: called CC=1 SCAR=0.0
624 9 ▶ , 'r' => sub { $_[0]->strftime('%I:%M:%S %p') }
Subroutine __ANON__: called CC=1 SCAR=0.0
625 4 ▶ , 'R' => sub { $_[0]->strftime('%H:%M') }
Subroutine __ANON__: called CC=1 SCAR=0.0
626 0 ▶ , 's' => sub { $_[0]->epoch }
Subroutine __ANON__: not called CC=1 SCAR=6.9
627 26 ▶ , 'S' => sub { sprintf('%02d', $_[0]->second) }
Subroutine __ANON__: called CC=1 SCAR=0.0
628 0 ▶ , 't' => sub { "\t" }
Subroutine __ANON__: not called CC=1 SCAR=6.9
629 5 ▶ , 'T' => sub { $_[0]->strftime('%H:%M:%S') }
Subroutine __ANON__: called CC=1 SCAR=0.0
630 5 ▶ , 'u' => sub { sprintf '%2d', $_[0]->day_of_decade },
Subroutine __ANON__: called CC=1 SCAR=0.0
631 4 ▶ , 'U' => sub { $_[0]->decade_number }
Subroutine __ANON__: called CC=1 SCAR=0.0
632 4 ▶ , 'V' => sub { $_[0]->decade_number }
Subroutine __ANON__: called CC=1 SCAR=0.0
633 5 ▶ , 'w' => sub { $_[0]->day_of_decade % 10 }
Subroutine __ANON__: called CC=1 SCAR=0.0
634 4 ▶ , 'W' => sub { $_[0]->decade_number }
Subroutine __ANON__: called CC=1 SCAR=0.0
635 12 ▶ , 'y' => sub { sprintf('%02d', substr( $_[0]->year, -2 )) }
Subroutine __ANON__: called CC=1 SCAR=0.0
636 25 ▶ , 'Y' => sub { sprintf '%04d', $_[0]->year }
Subroutine __ANON__: called CC=1 SCAR=0.0
637 4 ▶ , 'z' => sub { DateTime::TimeZone::offset_as_string( $_[0]->offset ) }
Subroutine __ANON__: called CC=1 SCAR=0.0
638 4 ▶ , 'Z' => sub { $_[0]->{tz}->short_name_for_datetime($_[0]) }
Subroutine __ANON__: called CC=1 SCAR=0.0
639 0 ▶ , '+' => sub { '+' }
Subroutine __ANON__: not called CC=1 SCAR=6.9
640 4 ▶ , '%' => sub { '%' }
Subroutine __ANON__: called CC=1 SCAR=0.0
641 114 ▶ , 'EY' => sub { Roman $_[0]->year || $_[0]->year }
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
&Roman(scalar $_[0]->year) or $_[0]->year 110 4 114
642 8 ▶ , 'Ey' => sub { roman $_[0]->year || $_[0]->year }
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
&roman(scalar $_[0]->year) or $_[0]->year 8 0 8
643 3 ▶ , '*' => sub { $_[0]->feast_long }
Subroutine __ANON__: called CC=1 SCAR=0.0
644 6 ▶ , 'Ej' => sub { $_[0]->feast_long }
Subroutine __ANON__: called CC=1 SCAR=0.0
645 34 ▶ , 'EJ' => sub { $_[0]->feast_caps }
Subroutine __ANON__: called CC=1 SCAR=0.0
646 2 ▶ , 'Oj' => sub { $_[0]->feast_short }
Subroutine __ANON__: called CC=1 SCAR=0.0
647  
648 17 );
649  
650 17 $formats{h} = $formats{b};
651  
652 199 ▶sub strftime {
Subroutine strftime: called CC=7 SCAR=19.5
Pod documented
653 199 my $self = shift;
654 # make a copy or caller's scalars get munged
655 199 my @formats = @_;
656  
657 199 my @r;
658 199 foreach my $f (@formats)
659 {
660 # regex from DateTime from Date::Format - thanks Graham and Dave!
661 # but there is a twist: 3-char format specifiers such as '%Ey' are
662 # allowed. All 3-char specifiers begin with a '%E' or '%O' prefix.
663 # At the same time, if the user wants %Em or %Om, which do not exist, it defaults to %m
664 # And if the user asks for %E!,
665 # it defaults to E! because neither %E! nor %! exist.
666 210 $f =~ s/
667 \%([EO]?([*%a-zA-Z]))
668 | \%\{(\w+)\}
669 /
670 $3 ? ($self->can($3) ? $self->$3() : "\%{$3}")
671 : ($formats{$1} ? $formats{$1}->($self)
672 957 ▶ : $formats{$2} ? $formats{$2}->($self) : $1)
Branch: 4 branches
BranchTrueFalseTotal
$3 ? : 214 743 957
$self->can($3) ? : 210 4 214
$formats{$1} ? : 723 20 743
$formats{$2} ? : 16 4 20
673 /sgex;
674 210 ▶ return $f unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 195 15 210
675 15 push @r, $f;
676 }
677 4 return @r;
678 }
679  
680 1 ▶sub epoch {
Subroutine epoch: called CC=1 SCAR=0.0
Pod documented
681 1 my $self = shift;
682 1 my $greg = DateTime->from_object(object => $self);
683 1 return $greg->epoch;
684 }
685  
686 177 ▶sub DefaultLocale {
Subroutine DefaultLocale: called CC=1 SCAR=0.0
Pod undocumented
687 177 'fr'
688 }
689  
690 #my %events = ();
691 6 ▶sub on_date {
Subroutine on_date: called CC=2 SCAR=6.9
Pod documented
692 6 my ($dt, $lan) = @_;
693 6 my $locale;
694  
695 6 ▶ if (defined $lan)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lan) { } 2 4 6
696 2 { $locale = DateTime::Calendar::FrenchRevolutionary::Locale->load( $lan )}
697 else
698 4 { $locale = $dt->{locale} }
699 6 return $locale->on_date($dt);
700  
701 }
702  
703 # A module must return a true value. Traditionally, a module returns 1.
704 # But this module is a revolutionary one, so it discards all old traditions.
705 17 "Liberté, égalité, fraternité
706 ou la mort !";
707  
708 __END__
↑ Summary FrenchRevolutionary/Locale.pm »