Calc/PP.pm

filter: Statementstmt 81.4% 1249 / 1533 Branchbran 65.3% 582 / 890 Conditioncond 57.2% 371 / 648 MC/DCmcdc 42.2% 147 / 348 Subroutinesub 84.0% 132 / 157 Podpod 0.6% 1 / 152 totaltotal 66.5% 2482 / 3728 CC 666 SCAR 47.0
CC
666
Cov
72%
DateCalc_mktime
1371.2
DateCalc_decode_date_us
138.4
Day_of_Week_Abbreviation
90.0
CRAP 110.0
↑ Summary Calc/Object.pm »
1  
2 ###############################################################################
3 ## ##
4 ## Copyright (c) 1995 - 2015 by Steffen Beyer. ##
5 ## All rights reserved. ##
6 ## ##
7 ## This package is free software; you can redistribute it ##
8 ## and/or modify it under the same terms as Perl itself. ##
9 ## ##
10 ###############################################################################
11  
12 package Date::Calc::PP;
13  
14 50 ▶BEGIN { eval { require bytes; }; }
Subroutine BEGIN: called CC=1 SCAR=0.0
15 50 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 50 ▶use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 50 ▶use Carp::Clan qw(^Date::);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 50 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 50 require Exporter;
23  
24 50 @ISA = qw(Exporter);
25  
26 50 @EXPORT = qw();
27  
28 50 @EXPORT_OK = qw(
29 Days_in_Year
30 Days_in_Month
31 Weeks_in_Year
32 leap_year
33 check_date
34 check_time
35 check_business_date
36 Day_of_Year
37 Date_to_Days
38 Day_of_Week
39 Week_Number
40 Week_of_Year
41 Monday_of_Week
42 Nth_Weekday_of_Month_Year
43 Standard_to_Business
44 Business_to_Standard
45 Delta_Days
46 Delta_DHMS
47 Delta_YMD
48 Delta_YMDHMS
49 N_Delta_YMD
50 N_Delta_YMDHMS
51 Normalize_DHMS
52 Add_Delta_Days
53 Add_Delta_DHMS
54 Add_Delta_YM
55 Add_Delta_YMD
56 Add_Delta_YMDHMS
57 Add_N_Delta_YMD
58 Add_N_Delta_YMDHMS
59 System_Clock
60 Today
61 Now
62 Today_and_Now
63 This_Year
64 Gmtime
65 Localtime
66 Mktime
67 Timezone
68 Date_to_Time
69 Time_to_Date
70 Easter_Sunday
71 Decode_Month
72 Decode_Day_of_Week
73 Decode_Language
74 Decode_Date_EU
75 Decode_Date_US
76 Fixed_Window
77 Moving_Window
78 Compress
79 Uncompress
80 check_compressed
81 Compressed_to_Text
82 Date_to_Text
83 Date_to_Text_Long
84 English_Ordinal
85 Calendar
86 Month_to_Text
87 Day_of_Week_to_Text
88 Day_of_Week_Abbreviation
89 Language_to_Text
90 Language
91 Languages
92 Decode_Date_EU2
93 Decode_Date_US2
94 Parse_Date
95 ISO_LC
96 ISO_UC
97 );
98  
99 50 %EXPORT_TAGS = (all => [@EXPORT_OK]);
100  
101 ##################################################
102 ## ##
103 ## "Version()" is available but not exported ##
104 ## in order to avoid possible name clashes. ##
105 ## Call "Date::Calc::PP::Version()" instead! ##
106 ## ##
107 ##################################################
108  
109 50 $VERSION = '6.4';
110  
111 sub Version
112 1 ▶{
Subroutine Version: called CC=1 SCAR=0.0
Pod documented
113 1 return $VERSION;
114 }
115  
116 #################
117 ## ##
118 ## Resources ##
119 ## ##
120 #################
121  
122 50 my $DateCalc_YEAR_OF_EPOCH = 70; # year of reference (epoch)
123 50 my $DateCalc_CENTURY_OF_EPOCH = 1900; # century of reference (epoch)
124 50 my $DateCalc_EPOCH = $DateCalc_CENTURY_OF_EPOCH + $DateCalc_YEAR_OF_EPOCH;
125  
126 50 my $DateCalc_DAYS_TO_EPOCH;
127 my $DateCalc_DAYS_TO_OVFLW;
128 50 my $DateCalc_SECS_TO_OVFLW;
129  
130 ## MacOS (Classic): ##
131 ## <695056.0> = Fri 1-Jan-1904 00:00:00 (time=0x00000000) ##
132 ## <744766.23295> = Mon 6-Feb-2040 06:28:15 (time=0xFFFFFFFF) ##
133  
134 ## Unix: ##
135 ## <719163.0> = Thu 1-Jan-1970 00:00:00 (time=0x00000000) ##
136 ## <744018.11647> = Tue 19-Jan-2038 03:14:07 (time=0x7FFFFFFF) ##
137  
138 50 ▶if ($^O eq 'MacOS')
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MacOS') { } 0 50 50
139 {
140 0 $DateCalc_DAYS_TO_EPOCH = 695056;
141 0 $DateCalc_DAYS_TO_OVFLW = 744766;
142 0 $DateCalc_SECS_TO_OVFLW = 23295;
143 }
144 else
145 {
146 50 $DateCalc_DAYS_TO_EPOCH = 719163;
147 50 $DateCalc_DAYS_TO_OVFLW = 744018;
148 50 $DateCalc_SECS_TO_OVFLW = 11647;
149 }
150  
151 50 my(@DateCalc_Days_in_Year_) =
152 (
153 [ 0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 ],
154 [ 0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 ]
155 );
156  
157 50 my(@DateCalc_Days_in_Month_) =
158 (
159 [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ],
160 [ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
161 );
162  
163 50 my $DateCalc_LANGUAGES = 14;
164  
165 50 my $DateCalc_Language = 1; # Default = 1 (English)
166  
167 50 my(@DateCalc_Month_to_Text_) =
168 (
169 [
170 "???", "???", "???", "???", "???", "???", "???",
171 "???", "???", "???", "???", "???", "???"
172 ],
173 [
174 "???", "January", "February", "March", "April", "May", "June",
175 "July", "August", "September", "October", "November", "December"
176 ],
177 [
178 "???", "janvier", "février", "mars", "avril", "mai", "juin",
179 "juillet", "août", "septembre", "octobre", "novembre", "décembre"
180 ],
181 [
182 "???", "Januar", "Februar", "März", "April", "Mai", "Juni",
183 "Juli", "August", "September", "Oktober", "November", "Dezember"
184 ],
185 [
186 "???", "enero", "febrero", "marzo", "abril", "mayo", "junio",
187 "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"
188 ],
189 [
190 "???", "janeiro", "fevereiro", "março", "abril", "maio", "junho",
191 "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"
192 ],
193 [
194 "???", "januari", "februari", "maart", "april", "mei", "juni",
195 "juli", "augustus", "september", "oktober", "november", "december"
196 ],
197 [
198 "???", "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno",
199 "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
200 ],
201 [
202 "???", "januar", "februar", "mars", "april", "mai", "juni",
203 "juli", "august", "september", "oktober", "november", "desember"
204 ],
205 [
206 "???", "januari", "februari", "mars", "april", "maj", "juni",
207 "juli", "augusti", "september", "oktober", "november", "december"
208 ],
209 [
210 "???", "januar", "februar", "marts", "april", "maj", "juni",
211 "juli", "august", "september", "oktober", "november", "december"
212 ],
213 [
214 "???", "tammikuu", "helmikuu", "maaliskuu", "huhtikuu",
215 "toukokuu", "kesäkuu", "heinäkuu", "elokuu",
216 "syyskuu", "lokakuu", "marraskuu", "joulukuu"
217 ],
218 [
219 "???", "Január", "Február", "Március", "Április", "Május", "Június",
220 "Július", "Augusztus", "Szeptember", "Október", "November", "December"
221 ],
222 [
223 "???", "Styczen", "Luty", "Marzec", "Kwiecien", "Maj", "Czerwiec", # ISO-Latin-1 approximation
224 "Lipiec", "Sierpien", "Wrzesien", "Pazdziernik", "Listopad", "Grudzien"
225 ],
226 [
227 "???", "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie",
228 "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"
229 ]
230 );
231  
232 50 my(@DateCalc_Day_of_Week_to_Text_) =
233 (
234 [
235 "???", "???", "???", "???",
236 "???", "???", "???", "???"
237 ],
238 [
239 "???", "Monday", "Tuesday", "Wednesday",
240 "Thursday", "Friday", "Saturday", "Sunday"
241 ],
242 [
243 "???", "Lundi", "Mardi", "Mercredi",
244 "Jeudi", "Vendredi", "Samedi", "Dimanche"
245 ],
246 [
247 "???", "Montag", "Dienstag", "Mittwoch",
248 "Donnerstag", "Freitag", "Samstag", "Sonntag"
249 ],
250 [
251 "???", "Lunes", "Martes", "Miércoles",
252 "Jueves", "Viernes", "Sábado", "Domingo"
253 ],
254 [
255 "???", "Segunda-feira", "Terça-feira", "Quarta-feira",
256 "Quinta-feira", "Sexta-feira", "Sábado", "Domingo"
257 ],
258 [
259 "???", "Maandag", "Dinsdag", "Woensdag",
260 "Donderdag", "Vrijdag", "Zaterdag", "Zondag"
261 ],
262 [
263 "???", "Lunedì", "Martedì", "Mercoledì",
264 "Giovedì", "Venerdì", "Sabato", "Domenica"
265 ],
266 [
267 "???", "mandag", "tirsdag", "onsdag",
268 "torsdag", "fredag", "lørdag", "søndag"
269 ],
270 [
271 "???", "måndag", "tisdag", "onsdag",
272 "torsdag", "fredag", "lördag", "söndag"
273 ],
274 [
275 "???", "mandag", "tirsdag", "onsdag",
276 "torsdag", "fredag", "lørdag", "søndag"
277 ],
278 [
279 "???", "maanantai", "tiistai", "keskiviikko",
280 "torstai", "perjantai", "lauantai", "sunnuntai"
281 ],
282 [
283 "???", "hétfõ", "kedd", "szerda",
284 "csütörtök", "péntek", "szombat", "vasárnap"
285 ],
286 [
287 "???", "poniedzialek", "wtorek", "sroda", # ISO-Latin-1 approximation
288 "czwartek", "piatek", "sobota", "niedziela"
289 ],
290 [
291 "???", "Luni", "Marti", "Miercuri",
292 "Joi", "Vineri", "Sambata", "Duminica"
293 ]
294 );
295  
296 50 my(@DateCalc_Day_of_Week_Abbreviation_) =
297 (
298 # Fill the fields below _only_ if special abbreviations are needed!
299 # Note that the first field serves as a flag and must be non-empty!
300 [
301 "", "", "", "", "", "", "", "" # 0 #
302 ],
303 [
304 "", "", "", "", "", "", "", "" # 1 #
305 ],
306 [
307 "", "", "", "", "", "", "", "" # 2 #
308 ],
309 [
310 "", "", "", "", "", "", "", "" # 3 #
311 ],
312 [
313 "", "", "", "", "", "", "", "" # 4 #
314 ],
315 [
316 "", "", "", "", "", "", "", "" # 5 #
317 # "???", "2ª", "3ª", "4ª", "5ª", "6ª", "Sáb", "Dom" # 5 #
318 ],
319 [
320 "", "", "", "", "", "", "", "" # 6 #
321 ],
322 [
323 "", "", "", "", "", "", "", "" # 7 #
324 ],
325 [
326 "", "", "", "", "", "", "", "" # 8 #
327 ],
328 [
329 "", "", "", "", "", "", "", "" # 9 #
330 ],
331 [
332 "", "", "", "", "", "", "", "" # 10 #
333 ],
334 [
335 "", "", "", "", "", "", "", "" # 11 #
336 ],
337 [
338 "", "", "", "", "", "", "", "" # 12 #
339 ],
340 [
341 "???", "Pn", "Wt", "Sr", "Cz", "Pt", "So", "Ni" # 13 # ISO-Latin-1 approximation
342 ],
343 [
344 "", "", "", "", "", "", "", "" # 14 #
345 ]
346 );
347  
348 50 my(@DateCalc_English_Ordinals_) =
349 (
350 "th",
351 "st",
352 "nd",
353 "rd"
354 );
355  
356 50 my(@DateCalc_Date_Long_Format_) =
357 (
358 "%s, %d %s %d", # 0 Default #
359 "%s, %s %s %d", # 1 English #
360 "%s %d %s %d", # 2 Français #
361 "%s, den %d. %s %d", # 3 Deutsch #
362 "%s, %d de %s de %d", # 4 Español #
363 "%s, dia %d de %s de %d", # 5 Português #
364 "%s, %d %s %d", # 6 Nederlands #
365 "%s, %d %s %d", # 7 Italiano #
366 "%s, %d. %s %d", # 8 Norsk #
367 "%s, %d %s %d", # 9 Svenska #
368 "%s, %d. %s %d", # 10 Dansk #
369 "%s, %d. %sta %d", # 11 suomi #
370 "%d. %s %d., %s", # 12 Magyar #
371 "%s, %d %s %d", # 13 polski #
372 "%s %d %s %d" # 14 Romaneste #
373 );
374  
375 50 my(@DateCalc_Language_to_Text_) =
376 (
377 "???", "English", "Français", "Deutsch", "Español",
378 "Português", "Nederlands", "Italiano", "Norsk", "Svenska",
379 "Dansk", "suomi", "Magyar", "polski", "Romaneste"
380 );
381  
382 ###############
383 ## ##
384 ## Calc.xs ##
385 ## ##
386 ###############
387  
388 ###############################################################################
389 ## ##
390 ## Copyright (c) 1995 - 2015 by Steffen Beyer. ##
391 ## All rights reserved. ##
392 ## ##
393 ## This package is free software; you can redistribute it ##
394 ## and/or modify it under the same terms as Perl itself. ##
395 ## ##
396 ###############################################################################
397  
398 sub DATECALC_USAGE
399 0 ▶{
Subroutine DATECALC_USAGE: not called CC=1 SCAR=6.9
Pod undocumented
400 0 croak('Usage: Date::Calc::' . $_[0]);
401 }
402 sub DATECALC_ERROR
403 0 ▶{
Subroutine DATECALC_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
404 0 croak("Date::Calc::$_[0](): $_[1]");
405 }
406 sub DATECALC_DATE_ERROR
407 32 ▶{
Subroutine DATECALC_DATE_ERROR: called CC=1 SCAR=0.0
Pod undocumented
408 32 croak("Date::Calc::$_[0](): not a valid date");
409 }
410 sub DATECALC_TIME_ERROR
411 17 ▶{
Subroutine DATECALC_TIME_ERROR: called CC=1 SCAR=0.0
Pod undocumented
412 17 croak("Date::Calc::$_[0](): not a valid time");
413 }
414 sub DATECALC_YEAR_ERROR
415 4 ▶{
Subroutine DATECALC_YEAR_ERROR: called CC=1 SCAR=0.0
Pod undocumented
416 4 croak("Date::Calc::$_[0](): year out of range");
417 }
418 sub DATECALC_MONTH_ERROR
419 17 ▶{
Subroutine DATECALC_MONTH_ERROR: called CC=1 SCAR=0.0
Pod undocumented
420 17 croak("Date::Calc::$_[0](): month out of range");
421 }
422 sub DATECALC_WEEK_ERROR
423 4 ▶{
Subroutine DATECALC_WEEK_ERROR: called CC=1 SCAR=0.0
Pod undocumented
424 4 croak("Date::Calc::$_[0](): week out of range");
425 }
426 sub DATECALC_DAYOFWEEK_ERROR
427 10 ▶{
Subroutine DATECALC_DAYOFWEEK_ERROR: called CC=1 SCAR=0.0
Pod undocumented
428 10 croak("Date::Calc::$_[0](): day of week out of range");
429 }
430 sub DATECALC_DATE_RANGE_ERROR
431 0 ▶{
Subroutine DATECALC_DATE_RANGE_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
432 0 croak("Date::Calc::$_[0](): date out of range");
433 }
434 sub DATECALC_TIME_RANGE_ERROR
435 0 ▶{
Subroutine DATECALC_TIME_RANGE_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
436 0 croak("Date::Calc::$_[0](): time out of range");
437 }
438 sub DATECALC_FACTOR_ERROR
439 0 ▶{
Subroutine DATECALC_FACTOR_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
440 0 croak("Date::Calc::$_[0](): factor out of range");
441 }
442 sub DATECALC_LANGUAGE_ERROR
443 1 ▶{
Subroutine DATECALC_LANGUAGE_ERROR: called CC=1 SCAR=0.0
Pod undocumented
444 1 croak("Date::Calc::$_[0](): language not available");
445 }
446 sub DATECALC_SYSTEM_ERROR
447 0 ▶{
Subroutine DATECALC_SYSTEM_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
448 0 croak("Date::Calc::$_[0](): not available on this system");
449 }
450 sub DATECALC_MEMORY_ERROR
451 0 ▶{
Subroutine DATECALC_MEMORY_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
452 0 croak("Date::Calc::$_[0](): unable to allocate memory");
453 }
454 sub DATECALC_STRING_ERROR
455 0 ▶{
Subroutine DATECALC_STRING_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
456 0 croak("Date::Calc::$_[0](): argument is not a string");
457 }
458 sub DATECALC_SCALAR_ERROR
459 0 ▶{
Subroutine DATECALC_SCALAR_ERROR: not called CC=1 SCAR=6.9
Pod undocumented
460 0 croak("Date::Calc::$_[0](): argument is not a scalar");
461 }
462  
463 sub Days_in_Year
464 191 ▶{
Subroutine Days_in_Year: called CC=5 SCAR=19.6
Pod undocumented
465 191 ▶ DATECALC_USAGE('Days_in_Year($year,$month)') unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 191 191
466 191 my($year,$month) = @_;
467 191 ▶ if ($year > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 0) { } 191 0 191
468 {
469 191 ▶ if (($month >= 1) and ($month <= 12))
Branch: 1 branch
BranchTrueFalseTotal
if ($month >= 1 and $month <= 12) { } 191 0 191
Condition33%1/3
$month >= 1 and $month <= 12
!ll&&!rl&&r
00191
MC/DC0%0/2
$month >= 1 and $month <= 12
$month >= 1 $month <= 12
Truth table33%1/3
A and B
A= $month >= 1B= $month <= 12
ABresult
0X0
100
111
470 {
471 191 return $DateCalc_Days_in_Year_[DateCalc_leap_year($year)][$month+1];
472 }
473 0 else { DATECALC_MONTH_ERROR('Days_in_Year'); }
474 }
475 0 else { DATECALC_YEAR_ERROR('Days_in_Year'); }
476 }
477  
478 sub Days_in_Month
479 26 ▶{
Subroutine Days_in_Month: called CC=5 SCAR=16.8
Pod undocumented
480 26 ▶ DATECALC_USAGE('Days_in_Month($year,$month)') unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 26 26
481 26 my($year,$month) = @_;
482 26 ▶ if ($year > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 0) { } 26 0 26
483 {
484 26 ▶ if (($month >= 1) and ($month <= 12))
Branch: 1 branch
BranchTrueFalseTotal
if ($month >= 1 and $month <= 12) { } 24 2 26
Condition66%2/3
$month >= 1 and $month <= 12
!ll&&!rl&&r
2024
MC/DC50%1/2
$month >= 1 and $month <= 12
$month >= 1 $month <= 12
Truth table66%2/3
A and B
A= $month >= 1B= $month <= 12
ABresult
0X0
100
111
485 {
486 24 return $DateCalc_Days_in_Month_[DateCalc_leap_year($year)][$month];
487 }
488 2 else { DATECALC_MONTH_ERROR('Days_in_Month'); }
489 }
490 0 else { DATECALC_YEAR_ERROR('Days_in_Month'); }
491 }
492  
493 sub Weeks_in_Year
494 4 ▶{
Subroutine Weeks_in_Year: called CC=3 SCAR=12.0
Pod undocumented
495 4 ▶ DATECALC_USAGE('Weeks_in_Year($year)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 4 4
496 4 my($year) = shift;
497 4 ▶ if ($year > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 0) { } 4 0 4
498 {
499 4 return DateCalc_Weeks_in_Year($year);
500 }
501 0 else { DATECALC_YEAR_ERROR('Weeks_in_Year'); }
502 }
503  
504 sub leap_year
505 4 ▶{
Subroutine leap_year: called CC=3 SCAR=12.0
Pod undocumented
506 4 ▶ DATECALC_USAGE('leap_year($year)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 4 4
507 4 my($year) = shift;
508 4 ▶ if ($year > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 0) { } 4 0 4
509 {
510 4 return DateCalc_leap_year($year);
511 }
512 0 else { DATECALC_YEAR_ERROR('leap_year'); }
513 }
514  
515 sub check_date
516 47213 ▶{
Subroutine check_date: called CC=2 SCAR=7.1
Pod undocumented
517 47213 ▶ DATECALC_USAGE('check_date($year,$month,$day)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 47213 47213
518 47213 my($year,$month,$day) = @_;
519 47213 return DateCalc_check_date($year,$month,$day);
520 }
521  
522 sub check_time
523 315 ▶{
Subroutine check_time: called CC=2 SCAR=7.1
Pod undocumented
524 315 ▶ DATECALC_USAGE('check_time($hour,$min,$sec)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 315 315
525 315 my($hour,$min,$sec) = @_;
526 315 return DateCalc_check_time($hour,$min,$sec);
527 }
528  
529 sub check_business_date
530 0 ▶{
Subroutine check_business_date: not called CC=2 SCAR=17.9
Pod undocumented
531 0 ▶ DATECALC_USAGE('check_business_date($year,$week,$dow)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
532 0 my($year,$week,$dow) = @_;
533 0 return DateCalc_check_business_date($year,$week,$dow);
534 }
535  
536 sub Day_of_Year
537 0 ▶{
Subroutine Day_of_Year: not called CC=3 SCAR=24.8
Pod undocumented
538 0 ▶ DATECALC_USAGE('Day_of_Year($year,$month,$day)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
539 0 my($year,$month,$day) = @_;
540 0 my $retval = DateCalc_Day_of_Year($year,$month,$day);
541 0 ▶ if ($retval == 0) { DATECALC_DATE_ERROR('Day_of_Year'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($retval == 0) 0 0 0
542 0 return $retval;
543 }
544  
545 sub Date_to_Days
546 24648 ▶{
Subroutine Date_to_Days: called CC=3 SCAR=11.8
Pod undocumented
547 24648 ▶ DATECALC_USAGE('Date_to_Days($year,$month,$day)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 24648 24648
548 24648 my($year,$month,$day) = @_;
549 24648 my $retval = DateCalc_Date_to_Days($year,$month,$day);
550 0 ▶ if ($retval == 0) { DATECALC_DATE_ERROR('Date_to_Days'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($retval == 0) 0 24648 24648
551 24648 return $retval;
552 }
553  
554 sub Day_of_Week
555 870 ▶{
Subroutine Day_of_Week: called CC=3 SCAR=11.0
Pod undocumented
556 870 ▶ DATECALC_USAGE('Day_of_Week($year,$month,$day)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 870 870
557 870 my($year,$month,$day) = @_;
558 870 my $retval = DateCalc_Day_of_Week($year,$month,$day);
559 870 ▶ if ($retval == 0) { DATECALC_DATE_ERROR('Day_of_Week'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($retval == 0) 1 869 870
560 869 return $retval;
561 }
562  
563 sub Week_Number
564 0 ▶{
Subroutine Week_Number: not called CC=3 SCAR=24.8
Pod undocumented
565 0 ▶ DATECALC_USAGE('Week_Number($year,$month,$day)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 0 0
566 0 my($year,$month,$day) = @_;
567 0 my($retval);
568 0 ▶ if (DateCalc_check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year, $month, $day)) { } 0 0 0
569 {
570 0 $retval = DateCalc_Week_Number($year,$month,$day);
571 }
572 0 else { DATECALC_DATE_ERROR('Week_Number'); }
573 0 return $retval;
574 }
575  
576 sub Week_of_Year
577 9 ▶{
Subroutine Week_of_Year: called CC=4 SCAR=14.2
Pod undocumented
578 9 ▶ DATECALC_USAGE('Week_of_Year($year,$month,$day)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 9 9
579 9 my($year,$month,$day) = @_;
580 9 my($week);
581 9 ▶ if (DateCalc_week_of_year(\$week,\$year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_week_of_year(\$week, \$year, $month, $day)) { } 7 2 9
582 {
583 7 ▶ if (wantarray) { return($week,$year); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 7 0 7
584 0 else { return $week; }
585 }
586 2 else { DATECALC_DATE_ERROR('Week_of_Year'); }
587 }
588  
589 sub Monday_of_Week
590 17 ▶{
Subroutine Monday_of_Week: called CC=6 SCAR=18.1
Pod undocumented
591 17 ▶ DATECALC_USAGE('Monday_of_Week($week,$year)') unless (@_ == 2);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 2 0 17 17
592 17 my($week,$year) = @_;
593 17 my($month,$day);
594 17 ▶ if ($year > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 0) { } 15 2 17
595 {
596 15 ▶ if (($week > 0) and ($week <= DateCalc_Weeks_in_Year($year)))
Branch: 1 branch
BranchTrueFalseTotal
if ($week > 0 and $week <= DateCalc_Weeks_in_Year($year)) { } 11 4 15
Condition100%3/3
$week > 0 and $week <= DateCalc_Weeks_in_Year($year)
!ll&&!rl&&r
2211
MC/DC100%2/2
$week > 0 and $week <= DateCalc_Weeks_in_Year($year)
$week > 0 $week <= DateCalc_Weeks_in_Year($year)
Truth table100%3/3
A and B
A= $week > 0B= $week <= DateCalc_Weeks_in_Year($year)
ABresult
0X0
100
111
597 {
598 11 ▶ if (DateCalc_monday_of_week($week,\$year,\$month,\$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_monday_of_week($week, \$year, \$month, \$day)) { } 11 0 11
599 {
600 11 return($year,$month,$day);
601 }
602 0 else { DATECALC_DATE_ERROR('Monday_of_Week'); }
603 }
604 4 else { DATECALC_WEEK_ERROR('Monday_of_Week'); }
605 }
606 2 else { DATECALC_YEAR_ERROR('Monday_of_Week'); }
607 }
608  
609 sub Nth_Weekday_of_Month_Year
610 1323 ▶{
Subroutine Nth_Weekday_of_Month_Year: called CC=10 SCAR=28.8
Pod undocumented
611 1323 ▶ DATECALC_USAGE('Nth_Weekday_of_Month_Year($year,$month,$dow,$n)') unless (@_ == 4);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 4 0 1323 1323
612 1323 my($year,$month,$dow,$n) = @_;
613 1323 my($day);
614 1323 ▶ if ($year > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 0) { } 1323 0 1323
615 {
616 1323 ▶ if (($month >= 1) and ($month <= 12))
Branch: 1 branch
BranchTrueFalseTotal
if ($month >= 1 and $month <= 12) { } 1323 0 1323
Condition33%1/3
$month >= 1 and $month <= 12
!ll&&!rl&&r
001323
MC/DC0%0/2
$month >= 1 and $month <= 12
$month >= 1 $month <= 12
Truth table33%1/3
A and B
A= $month >= 1B= $month <= 12
ABresult
0X0
100
111
617 {
618 1323 ▶ if (($dow >= 1) and ($dow <= 7))
Branch: 1 branch
BranchTrueFalseTotal
if ($dow >= 1 and $dow <= 7) { } 1323 0 1323
Condition33%1/3
$dow >= 1 and $dow <= 7
!ll&&!rl&&r
001323
MC/DC0%0/2
$dow >= 1 and $dow <= 7
$dow >= 1 $dow <= 7
Truth table33%1/3
A and B
A= $dow >= 1B= $dow <= 7
ABresult
0X0
100
111
619 {
620 1323 ▶ if (($n >= 1) and ($n <= 5))
Branch: 1 branch
BranchTrueFalseTotal
if ($n >= 1 and $n <= 5) { } 1323 0 1323
Condition33%1/3
$n >= 1 and $n <= 5
!ll&&!rl&&r
001323
MC/DC0%0/2
$n >= 1 and $n <= 5
$n >= 1 $n <= 5
Truth table33%1/3
A and B
A= $n >= 1B= $n <= 5
ABresult
0X0
100
111
621 {
622 1323 ▶ if (DateCalc_nth_weekday_of_month_year(\$year,\$month,\$day,$dow,$n))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_nth_weekday_of_month_year(\$year, \$month, \$day, $dow, $n)) { } 1252 71 1323
623 {
624 1252 return($year,$month,$day);
625 }
626 71 else { return(); }
627 }
628 0 else { DATECALC_FACTOR_ERROR('Nth_Weekday_of_Month_Year'); }
629 }
630 0 else { DATECALC_DAYOFWEEK_ERROR('Nth_Weekday_of_Month_Year'); }
631 }
632 0 else { DATECALC_MONTH_ERROR('Nth_Weekday_of_Month_Year'); }
633 }
634 0 else { DATECALC_YEAR_ERROR('Nth_Weekday_of_Month_Year'); }
635 }
636  
637 sub Standard_to_Business
638 629 ▶{
Subroutine Standard_to_Business: called CC=3 SCAR=11.8
Pod undocumented
639 629 ▶ DATECALC_USAGE('Standard_to_Business($year,$month,$day)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 629 629
640 629 my($year,$month,$day) = @_;
641 629 my($week,$dow);
642 629 ▶ if (DateCalc_standard_to_business(\$year,\$week,\$dow,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_standard_to_business(\$year, \$week, \$dow, $month, $day)) { } 629 0 629
643 {
644 629 return($year,$week,$dow);
645 }
646 0 else { DATECALC_DATE_ERROR('Standard_to_Business'); }
647 }
648  
649 sub Business_to_Standard
650 629 ▶{
Subroutine Business_to_Standard: called CC=3 SCAR=11.8
Pod undocumented
651 629 ▶ DATECALC_USAGE('Business_to_Standard($year,$week,$dow)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 629 629
652 629 my($year,$week,$dow) = @_;
653 629 my($month,$day);
654 629 ▶ if (DateCalc_business_to_standard(\$year,\$month,\$day,$week,$dow))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_business_to_standard(\$year, \$month, \$day, $week, $dow)) { } 629 0 629
655 {
656 629 return($year,$month,$day);
657 }
658 0 else { DATECALC_DATE_ERROR('Business_to_Standard'); }
659 }
660  
661 sub Delta_Days
662 15 ▶{
Subroutine Delta_Days: called CC=4 SCAR=13.9
Pod undocumented
663 15 ▶ DATECALC_USAGE('Delta_Days($year1,$month1,$day1,$year2,$month2,$day2)') unless (@_ == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 6 0 15 15
664 15 my($year1,$month1,$day1,$year2,$month2,$day2) = @_;
665 15 my($retval);
666 15 ▶ if (DateCalc_check_date($year1,$month1,$day1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)) { } 12 3 15
Condition100%3/3
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
!ll&&!rl&&r
2112
MC/DC100%2/2
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
DateCalc_check_date($year1, $month1, $day1) DateCalc_check_date($year2, $month2, $day2)
Truth table100%3/3
A and B
A= DateCalc_check_date($year1, $month1, $day1)B= DateCalc_check_date($year2, $month2, $day2)
ABresult
0X0
100
111
667 DateCalc_check_date($year2,$month2,$day2))
668 {
669 12 $retval = DateCalc_Delta_Days($year1,$month1,$day1, $year2,$month2,$day2);
670 }
671 3 else { DATECALC_DATE_ERROR('Delta_Days'); }
672 12 return $retval;
673 }
674  
675 sub Delta_DHMS
676 32 ▶{
Subroutine Delta_DHMS: called CC=7 SCAR=19.6
Pod undocumented
677 32 ▶ DATECALC_USAGE('Delta_DHMS($year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2)') unless (@_ == 12);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 12 0 32 32
678 32 my($year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2) = @_;
679 32 my($Dd,$Dh,$Dm,$Ds);
680 32 ▶ if (DateCalc_check_date($year1,$month1,$day1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)) { } 29 3 32
Condition100%3/3
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
!ll&&!rl&&r
2129
MC/DC100%2/2
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
DateCalc_check_date($year1, $month1, $day1) DateCalc_check_date($year2, $month2, $day2)
Truth table100%3/3
A and B
A= DateCalc_check_date($year1, $month1, $day1)B= DateCalc_check_date($year2, $month2, $day2)
ABresult
0X0
100
111
681 DateCalc_check_date($year2,$month2,$day2))
682 {
683 29 ▶ if (DateCalc_check_time($hour1,$min1,$sec1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)) { } 17 12 29
Condition100%3/3
DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)
!ll&&!rl&&r
6617
MC/DC100%2/2
DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)
DateCalc_check_time($hour1, $min1, $sec1) DateCalc_check_time($hour2, $min2, $sec2)
Truth table100%3/3
A and B
A= DateCalc_check_time($hour1, $min1, $sec1)B= DateCalc_check_time($hour2, $min2, $sec2)
ABresult
0X0
100
111
684 DateCalc_check_time($hour2,$min2,$sec2))
685 {
686 17 ▶ if (DateCalc_delta_dhms(\$Dd,\$Dh,\$Dm,\$Ds,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_delta_dhms(\$Dd, \$Dh, \$Dm, \$Ds, $year1, $month1, $day1, $hour1, $min1, $sec1, $year2, $month2, $day2, $hour2, $min2, $sec2)) { } 17 0 17
687 $year1,$month1,$day1, $hour1,$min1,$sec1,
688 $year2,$month2,$day2, $hour2,$min2,$sec2))
689 {
690 17 return($Dd,$Dh,$Dm,$Ds);
691 }
692 0 else { DATECALC_DATE_ERROR('Delta_DHMS'); }
693 }
694 12 else { DATECALC_TIME_ERROR('Delta_DHMS'); }
695 }
696 3 else { DATECALC_DATE_ERROR('Delta_DHMS'); }
697 }
698  
699 sub Delta_YMD
700 5 ▶{
Subroutine Delta_YMD: called CC=3 SCAR=12.0
Pod undocumented
701 5 ▶ DATECALC_USAGE('Delta_YMD($year1,$month1,$day1,$year2,$month2,$day2)') unless (@_ == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 6 0 5 5
702 5 my($year1,$month1,$day1,$year2,$month2,$day2) = @_;
703 5 ▶ if (DateCalc_delta_ymd(\$year1,\$month1,\$day1, $year2,$month2,$day2))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_delta_ymd(\$year1, \$month1, \$day1, $year2, $month2, $day2)) { } 5 0 5
704 {
705 5 return($year1,$month1,$day1);
706 }
707 0 else { DATECALC_DATE_ERROR('Delta_YMD'); }
708 }
709  
710 sub Delta_YMDHMS
711 3 ▶{
Subroutine Delta_YMDHMS: called CC=7 SCAR=24.6
Pod undocumented
712 3 ▶ DATECALC_USAGE('Delta_YMDHMS($year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2)') unless (@_ == 12);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 12 0 3 3
713 3 my($year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2) = @_;
714 3 my($D_y,$D_m,$D_d,$Dh,$Dm,$Ds);
715 3 ▶ if (DateCalc_check_date($year1,$month1,$day1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)) { } 3 0 3
Condition33%1/3
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
!ll&&!rl&&r
003
MC/DC0%0/2
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
DateCalc_check_date($year1, $month1, $day1) DateCalc_check_date($year2, $month2, $day2)
Truth table33%1/3
A and B
A= DateCalc_check_date($year1, $month1, $day1)B= DateCalc_check_date($year2, $month2, $day2)
ABresult
0X0
100
111
716 DateCalc_check_date($year2,$month2,$day2))
717 {
718 3 ▶ if (DateCalc_check_time($hour1,$min1,$sec1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)) { } 3 0 3
Condition33%1/3
DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)
!ll&&!rl&&r
003
MC/DC0%0/2
DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)
DateCalc_check_time($hour1, $min1, $sec1) DateCalc_check_time($hour2, $min2, $sec2)
Truth table33%1/3
A and B
A= DateCalc_check_time($hour1, $min1, $sec1)B= DateCalc_check_time($hour2, $min2, $sec2)
ABresult
0X0
100
111
719 DateCalc_check_time($hour2,$min2,$sec2))
720 {
721 3 ▶ if (DateCalc_delta_ymdhms(\$D_y,\$D_m,\$D_d, \$Dh,\$Dm,\$Ds,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_delta_ymdhms(\$D_y, \$D_m, \$D_d, \$Dh, \$Dm, \$Ds, $year1, $month1, $day1, $hour1, $min1, $sec1, $year2, $month2, $day2, $hour2, $min2, $sec2)) { } 3 0 3
722 $year1,$month1,$day1, $hour1,$min1,$sec1,
723 $year2,$month2,$day2, $hour2,$min2,$sec2))
724 {
725 3 return($D_y,$D_m,$D_d,$Dh,$Dm,$Ds);
726 }
727 0 else { DATECALC_DATE_ERROR('Delta_YMDHMS'); }
728 }
729 0 else { DATECALC_TIME_ERROR('Delta_YMDHMS'); }
730 }
731 0 else { DATECALC_DATE_ERROR('Delta_YMDHMS'); }
732 }
733  
734 sub N_Delta_YMD
735 82 ▶{
Subroutine N_Delta_YMD: called CC=3 SCAR=11.0
Pod undocumented
736 82 ▶ DATECALC_USAGE('N_Delta_YMD($year1,$month1,$day1,$year2,$month2,$day2)') unless (@_ == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 6 0 82 82
737 82 my($year1,$month1,$day1,$year2,$month2,$day2) = @_;
738 82 ▶ if (DateCalc_norm_delta_ymd(\$year1,\$month1,\$day1, $year2,$month2,$day2))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_norm_delta_ymd(\$year1, \$month1, \$day1, $year2, $month2, $day2)) { } 74 8 82
739 {
740 74 return($year1,$month1,$day1);
741 }
742 8 else { DATECALC_DATE_ERROR('N_Delta_YMD'); }
743 }
744  
745 sub N_Delta_YMDHMS
746 84 ▶{
Subroutine N_Delta_YMDHMS: called CC=7 SCAR=19.6
Pod undocumented
747 84 ▶ DATECALC_USAGE('N_Delta_YMDHMS($year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2)') unless (@_ == 12);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 12 0 84 84
748 84 my($year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2) = @_;
749 84 my($D_y,$D_m,$D_d,$Dhh,$Dmm,$Dss);
750 84 ▶ if (DateCalc_check_date($year1,$month1,$day1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)) { } 82 2 84
Condition100%3/3
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
!ll&&!rl&&r
1182
MC/DC100%2/2
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
DateCalc_check_date($year1, $month1, $day1) DateCalc_check_date($year2, $month2, $day2)
Truth table100%3/3
A and B
A= DateCalc_check_date($year1, $month1, $day1)B= DateCalc_check_date($year2, $month2, $day2)
ABresult
0X0
100
111
751 DateCalc_check_date($year2,$month2,$day2))
752 {
753 82 ▶ if (DateCalc_check_time($hour1,$min1,$sec1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)) { } 80 2 82
Condition100%3/3
DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)
!ll&&!rl&&r
1180
MC/DC100%2/2
DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)
DateCalc_check_time($hour1, $min1, $sec1) DateCalc_check_time($hour2, $min2, $sec2)
Truth table100%3/3
A and B
A= DateCalc_check_time($hour1, $min1, $sec1)B= DateCalc_check_time($hour2, $min2, $sec2)
ABresult
0X0
100
111
754 DateCalc_check_time($hour2,$min2,$sec2))
755 {
756 80 ▶ if (DateCalc_norm_delta_ymdhms(\$D_y,\$D_m,\$D_d, \$Dhh,\$Dmm,\$Dss,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_norm_delta_ymdhms(\$D_y, \$D_m, \$D_d, \$Dhh, \$Dmm, \$Dss, $year1, $month1, $day1, $hour1, $min1, $sec1, $year2, $month2, $day2, $hour2, $min2, $sec2)) { } 80 0 80
757 $year1,$month1,$day1, $hour1,$min1,$sec1,
758 $year2,$month2,$day2, $hour2,$min2,$sec2))
759 {
760 80 return($D_y,$D_m,$D_d,$Dhh,$Dmm,$Dss);
761 }
762 0 else { DATECALC_DATE_ERROR('N_Delta_YMDHMS'); }
763 }
764 2 else { DATECALC_TIME_ERROR('N_Delta_YMDHMS'); }
765 }
766 2 else { DATECALC_DATE_ERROR('N_Delta_YMDHMS'); }
767 }
768  
769 sub Normalize_DHMS
770 14 ▶{
Subroutine Normalize_DHMS: called CC=2 SCAR=7.0
Pod undocumented
771 14 ▶ DATECALC_USAGE('Normalize_DHMS($Dd,$Dh,$Dm,$Ds)') unless (@_ == 4);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 4 0 14 14
772 14 my($Dd,$Dh,$Dm,$Ds) = @_;
773 14 DateCalc_Normalize_DHMS(\$Dd,\$Dh,\$Dm,\$Ds);
774 14 return($Dd,$Dh,$Dm,$Ds);
775 }
776  
777 sub Add_Delta_Days
778 2213 ▶{
Subroutine Add_Delta_Days: called CC=3 SCAR=11.0
Pod undocumented
779 2213 ▶ DATECALC_USAGE('Add_Delta_Days($year,$month,$day,$Dd)') unless (@_ == 4);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 4 0 2213 2213
780 2213 my($year,$month,$day,$Dd) = @_;
781 2213 ▶ if (DateCalc_add_delta_days(\$year,\$month,\$day, $Dd))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_add_delta_days(\$year, \$month, \$day, $Dd)) { } 2210 3 2213
782 {
783 2210 return($year,$month,$day);
784 }
785 3 else { DATECALC_DATE_ERROR('Add_Delta_Days'); }
786 }
787  
788 sub Add_Delta_DHMS
789 56 ▶{
Subroutine Add_Delta_DHMS: called CC=5 SCAR=16.1
Pod undocumented
790 56 ▶ DATECALC_USAGE('Add_Delta_DHMS($year,$month,$day,$hour,$min,$sec,$Dd,$Dh,$Dm,$Ds)') unless (@_ == 10);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 10 0 56 56
791 56 my($year,$month,$day,$hour,$min,$sec,$Dd,$Dh,$Dm,$Ds) = @_;
792 56 ▶ if (DateCalc_check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year, $month, $day)) { } 55 1 56
793 {
794 55 ▶ if (DateCalc_check_time($hour,$min,$sec))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_time($hour, $min, $sec)) { } 52 3 55
795 {
796 52 ▶ if (DateCalc_add_delta_dhms(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_add_delta_dhms(\$year, \$month, \$day, \$hour, \$min, \$sec, $Dd, $Dh, $Dm, $Ds)) { } 51 1 52
797 \$hour,\$min,\$sec,
798 $Dd,$Dh,$Dm,$Ds))
799 {
800 51 return($year,$month,$day,$hour,$min,$sec);
801 }
802 1 else { DATECALC_DATE_ERROR('Add_Delta_DHMS'); }
803 }
804 3 else { DATECALC_TIME_ERROR('Add_Delta_DHMS'); }
805 }
806 1 else { DATECALC_DATE_ERROR('Add_Delta_DHMS'); }
807 }
808  
809 sub Add_Delta_YM
810 74 ▶{
Subroutine Add_Delta_YM: called CC=3 SCAR=12.0
Pod undocumented
811 74 ▶ DATECALC_USAGE('Add_Delta_YM($year,$month,$day,$Dy,$Dm)') unless (@_ == 5);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 5 0 74 74
812 74 my($year,$month,$day,$Dy,$Dm) = @_;
813 74 ▶ if (DateCalc_add_delta_ym(\$year,\$month,\$day, $Dy,$Dm))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_add_delta_ym(\$year, \$month, \$day, $Dy, $Dm)) { } 74 0 74
814 {
815 74 return($year,$month,$day);
816 }
817 0 else { DATECALC_DATE_ERROR('Add_Delta_YM'); }
818 }
819  
820 sub Add_Delta_YMD
821 53 ▶{
Subroutine Add_Delta_YMD: called CC=3 SCAR=11.0
Pod undocumented
822 53 ▶ DATECALC_USAGE('Add_Delta_YMD($year,$month,$day,$Dy,$Dm,$Dd)') unless (@_ == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 6 0 53 53
823 53 my($year,$month,$day,$Dy,$Dm,$Dd) = @_;
824 53 ▶ if (DateCalc_add_delta_ymd(\$year,\$month,\$day, $Dy,$Dm,$Dd))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_add_delta_ymd(\$year, \$month, \$day, $Dy, $Dm, $Dd)) { } 45 8 53
825 {
826 45 return($year,$month,$day);
827 }
828 8 else { DATECALC_DATE_ERROR('Add_Delta_YMD'); }
829 }
830  
831 sub Add_Delta_YMDHMS
832 6 ▶{
Subroutine Add_Delta_YMDHMS: called CC=5 SCAR=19.1
Pod undocumented
833 6 ▶ DATECALC_USAGE('Add_Delta_YMDHMS($year,$month,$day,$hour,$min,$sec,$D_y,$D_m,$D_d,$Dh,$Dm,$Ds)') unless (@_ == 12);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 12 0 6 6
834 6 my($year,$month,$day,$hour,$min,$sec,$D_y,$D_m,$D_d,$Dh,$Dm,$Ds) = @_;
835 6 ▶ if (DateCalc_check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year, $month, $day)) { } 6 0 6
836 {
837 6 ▶ if (DateCalc_check_time($hour,$min,$sec))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_time($hour, $min, $sec)) { } 6 0 6
838 {
839 6 ▶ if (DateCalc_add_delta_ymdhms(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_add_delta_ymdhms(\$year, \$month, \$day, \$hour, \$min, \$sec, $D_y, $D_m, $D_d, $Dh, $Dm, $Ds)) { } 6 0 6
840 \$hour,\$min,\$sec,
841 $D_y,$D_m,$D_d,
842 $Dh,$Dm,$Ds))
843 {
844 6 return($year,$month,$day,$hour,$min,$sec);
845 }
846 0 else { DATECALC_DATE_ERROR('Add_Delta_YMDHMS'); }
847 }
848 0 else { DATECALC_TIME_ERROR('Add_Delta_YMDHMS'); }
849 }
850 0 else { DATECALC_DATE_ERROR('Add_Delta_YMDnMS'); }
851 }
852  
853 sub Add_N_Delta_YMD
854 96 ▶{
Subroutine Add_N_Delta_YMD: called CC=3 SCAR=12.0
Pod undocumented
855 96 ▶ DATECALC_USAGE('Add_N_Delta_YMD($year,$month,$day,$Dy,$Dm,$Dd)') unless (@_ == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 6 0 96 96
856 96 my($year,$month,$day,$Dy,$Dm,$Dd) = @_;
857 96 ▶ if (DateCalc_add_norm_delta_ymd(\$year,\$month,\$day, $Dy,$Dm,$Dd))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_add_norm_delta_ymd(\$year, \$month, \$day, $Dy, $Dm, $Dd)) { } 96 0 96
858 {
859 96 return($year,$month,$day);
860 }
861 0 else { DATECALC_DATE_ERROR('Add_N_Delta_YMD'); }
862 }
863  
864 sub Add_N_Delta_YMDHMS
865 80 ▶{
Subroutine Add_N_Delta_YMDHMS: called CC=5 SCAR=19.1
Pod undocumented
866 80 ▶ DATECALC_USAGE('Add_N_Delta_YMDHMS($year,$month,$day,$hour,$min,$sec,$D_y,$D_m,$D_d,$Dhh,$Dmm,$Dss)') unless (@_ == 12);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 12 0 80 80
867 80 my($year,$month,$day,$hour,$min,$sec,$D_y,$D_m,$D_d,$Dhh,$Dmm,$Dss) = @_;
868 80 ▶ if (DateCalc_check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year, $month, $day)) { } 80 0 80
869 {
870 80 ▶ if (DateCalc_check_time($hour,$min,$sec))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_time($hour, $min, $sec)) { } 80 0 80
871 {
872 80 ▶ if (DateCalc_add_norm_delta_ymdhms(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_add_norm_delta_ymdhms(\$year, \$month, \$day, \$hour, \$min, \$sec, $D_y, $D_m, $D_d, $Dhh, $Dmm, $Dss)) { } 80 0 80
873 \$hour,\$min,\$sec,
874 $D_y,$D_m,$D_d,
875 $Dhh,$Dmm,$Dss))
876 {
877 80 return($year,$month,$day,$hour,$min,$sec);
878 }
879 0 else { DATECALC_DATE_ERROR('Add_N_Delta_YMDHMS'); }
880 }
881 0 else { DATECALC_TIME_ERROR('Add_N_Delta_YMDHMS'); }
882 }
883 0 else { DATECALC_DATE_ERROR('Add_N_Delta_YMDHMS'); }
884 }
885  
886 sub System_Clock
887 0 ▶{
Subroutine System_Clock: not called CC=5 SCAR=34.0
Pod undocumented
888 0 ▶ DATECALC_USAGE('System_Clock([$gmt])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 0 0
Condition0%0/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table0%0/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
889 0 my($year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst,$gmt);
890 0 ▶ if (@_ == 1) { $gmt = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
891 0 else { $gmt = 0; }
892 0 ▶ if (DateCalc_system_clock(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_system_clock(\$year, \$month, \$day, \$hour, \$min, \$sec, \$doy, \$dow, \$dst, $gmt)) { } 0 0 0
893 \$hour,\$min,\$sec,
894 \$doy,\$dow,\$dst,
895 $gmt))
896 {
897 0 return($year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst);
898 }
899 0 else { DATECALC_SYSTEM_ERROR('System_Clock'); }
900 }
901  
902 sub Today
903 0 ▶{
Subroutine Today: not called CC=5 SCAR=34.0
Pod undocumented
904 0 ▶ DATECALC_USAGE('Today([$gmt])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 0 0
Condition0%0/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table0%0/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
905 0 my($year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst,$gmt);
906 0 ▶ if (@_ == 1) { $gmt = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
907 0 else { $gmt = 0; }
908 0 ▶ if (DateCalc_system_clock(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_system_clock(\$year, \$month, \$day, \$hour, \$min, \$sec, \$doy, \$dow, \$dst, $gmt)) { } 0 0 0
909 \$hour,\$min,\$sec,
910 \$doy,\$dow,\$dst,
911 $gmt))
912 {
913 0 return($year,$month,$day);
914 }
915 0 else { DATECALC_SYSTEM_ERROR('Today'); }
916 }
917  
918 sub Now
919 0 ▶{
Subroutine Now: not called CC=5 SCAR=34.0
Pod undocumented
920 0 ▶ DATECALC_USAGE('Now([$gmt])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 0 0
Condition0%0/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table0%0/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
921 0 my($year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst,$gmt);
922 0 ▶ if (@_ == 1) { $gmt = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
923 0 else { $gmt = 0; }
924 0 ▶ if (DateCalc_system_clock(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_system_clock(\$year, \$month, \$day, \$hour, \$min, \$sec, \$doy, \$dow, \$dst, $gmt)) { } 0 0 0
925 \$hour,\$min,\$sec,
926 \$doy,\$dow,\$dst,
927 $gmt))
928 {
929 0 return($hour,$min,$sec);
930 }
931 0 else { DATECALC_SYSTEM_ERROR('Now'); }
932 }
933  
934 sub Today_and_Now
935 1 ▶{
Subroutine Today_and_Now: called CC=5 SCAR=19.1
Pod undocumented
936 1 ▶ DATECALC_USAGE('Today_and_Now([$gmt])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 1 1
Condition33%1/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
100
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table33%1/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
937 1 my($year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst,$gmt);
938 0 ▶ if (@_ == 1) { $gmt = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 1 1
939 1 else { $gmt = 0; }
940 1 ▶ if (DateCalc_system_clock(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_system_clock(\$year, \$month, \$day, \$hour, \$min, \$sec, \$doy, \$dow, \$dst, $gmt)) { } 1 0 1
941 \$hour,\$min,\$sec,
942 \$doy,\$dow,\$dst,
943 $gmt))
944 {
945 1 return($year,$month,$day,$hour,$min,$sec);
946 }
947 0 else { DATECALC_SYSTEM_ERROR('Today_and_Now'); }
948 }
949  
950 sub This_Year
951 0 ▶{
Subroutine This_Year: not called CC=5 SCAR=34.0
Pod undocumented
952 0 ▶ DATECALC_USAGE('This_Year([$gmt])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 0 0
Condition0%0/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table0%0/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
953 0 my($year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst,$gmt);
954 0 ▶ if (@_ == 1) { $gmt = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
955 0 else { $gmt = 0; }
956 0 ▶ if (DateCalc_system_clock(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_system_clock(\$year, \$month, \$day, \$hour, \$min, \$sec, \$doy, \$dow, \$dst, $gmt)) { } 0 0 0
957 \$hour,\$min,\$sec,
958 \$doy,\$dow,\$dst,
959 $gmt))
960 {
961 0 return($year);
962 }
963 0 else { DATECALC_SYSTEM_ERROR('This_Year'); }
964 }
965  
966 sub Gmtime
967 2 ▶{
Subroutine Gmtime: called CC=7 SCAR=24.6
Pod undocumented
968 2 ▶ DATECALC_USAGE('Gmtime([time])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 2 2
Condition33%1/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
200
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table33%1/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
969 2 my($seconds,$year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst);
970 0 ▶ if (@_ == 1) { $seconds = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 2 2
971 2 else { $seconds = time; }
972 0 ▶ if (($seconds < 0) or ($seconds > 0xFFFFFFFF)) { DATECALC_TIME_RANGE_ERROR('Gmtime'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds < 0 or $seconds > 4294967295) 0 2 2
Condition33%1/3
$seconds < 0 or $seconds > 4294967295
l!l&&r!l&&!r
002
MC/DC0%0/2
$seconds < 0 or $seconds > 4294967295
$seconds < 0 $seconds > 4294967295
Truth table33%1/3
A or B
A= $seconds < 0B= $seconds > 4294967295
ABresult
1X1
011
000
973 2 ▶ if (DateCalc_gmtime(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_gmtime(\$year, \$month, \$day, \$hour, \$min, \$sec, \$doy, \$dow, \$dst, $seconds)) { } 2 0 2
974 \$hour,\$min,\$sec,
975 \$doy,\$dow,\$dst,
976 $seconds))
977 {
978 2 return($year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst);
979 }
980 0 else { DATECALC_TIME_RANGE_ERROR('Gmtime'); }
981 }
982  
983 sub Localtime
984 2 ▶{
Subroutine Localtime: called CC=7 SCAR=24.6
Pod undocumented
985 2 ▶ DATECALC_USAGE('Localtime([time])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 2 2
Condition33%1/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
200
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table33%1/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
986 2 my($seconds,$year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst);
987 0 ▶ if (@_ == 1) { $seconds = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 2 2
988 2 else { $seconds = time; }
989 0 ▶ if (($seconds < 0) or ($seconds > 0xFFFFFFFF)) { DATECALC_TIME_RANGE_ERROR('Localtime'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds < 0 or $seconds > 4294967295) 0 2 2
Condition33%1/3
$seconds < 0 or $seconds > 4294967295
l!l&&r!l&&!r
002
MC/DC0%0/2
$seconds < 0 or $seconds > 4294967295
$seconds < 0 $seconds > 4294967295
Truth table33%1/3
A or B
A= $seconds < 0B= $seconds > 4294967295
ABresult
1X1
011
000
990 2 ▶ if (DateCalc_localtime(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_localtime(\$year, \$month, \$day, \$hour, \$min, \$sec, \$doy, \$dow, \$dst, $seconds)) { } 2 0 2
991 \$hour,\$min,\$sec,
992 \$doy,\$dow,\$dst,
993 $seconds))
994 {
995 2 return($year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst);
996 }
997 0 else { DATECALC_TIME_RANGE_ERROR('Localtime'); }
998 }
999  
1000 sub Mktime
1001 2 ▶{
Subroutine Mktime: called CC=3 SCAR=11.8
Pod undocumented
1002 2 ▶ DATECALC_USAGE('Mktime($year,$month,$day,$hour,$min,$sec)') unless (@_ == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 6 0 2 2
1003 2 my($year,$month,$day,$hour,$min,$sec) = @_;
1004 2 my($seconds);
1005 2 ▶ if (DateCalc_mktime(\$seconds, $year,$month,$day, $hour,$min,$sec, -1,-1,-1))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_mktime(\$seconds, $year, $month, $day, $hour, $min, $sec, -1, -1, -1)) { } 2 0 2
1006 {
1007 2 return $seconds;
1008 }
1009 0 else { DATECALC_DATE_RANGE_ERROR('Mktime'); }
1010 }
1011  
1012 sub Timezone
1013 0 ▶{
Subroutine Timezone: not called CC=7 SCAR=40.3
Pod undocumented
1014 0 ▶ DATECALC_USAGE('Timezone([time])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 0 0
Condition0%0/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table0%0/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
1015 0 my($when,$year,$month,$day,$hour,$min,$sec,$dst);
1016 0 ▶ if (@_ == 1) { $when = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
1017 0 else { $when = time; }
1018 0 ▶ if (($when < 0) or ($when > 0xFFFFFFFF)) { DATECALC_TIME_RANGE_ERROR('Timezone'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($when < 0 or $when > 4294967295) 0 0 0
Condition0%0/3
$when < 0 or $when > 4294967295
l!l&&r!l&&!r
000
MC/DC0%0/2
$when < 0 or $when > 4294967295
$when < 0 $when > 4294967295
Truth table0%0/3
A or B
A= $when < 0B= $when > 4294967295
ABresult
1X1
011
000
1019 0 ▶ if (DateCalc_timezone(\$year,\$month,\$day,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_timezone(\$year, \$month, \$day, \$hour, \$min, \$sec, \$dst, $when)) { } 0 0 0
1020 \$hour,\$min,\$sec,
1021 \$dst,$when))
1022 {
1023 0 return($year,$month,$day,$hour,$min,$sec,$dst);
1024 }
1025 0 else { DATECALC_TIME_RANGE_ERROR('Timezone'); }
1026 }
1027  
1028 sub Date_to_Time
1029 6 ▶{
Subroutine Date_to_Time: called CC=3 SCAR=11.8
Pod undocumented
1030 6 ▶ DATECALC_USAGE('Date_to_Time($year,$month,$day,$hour,$min,$sec)') unless (@_ == 6);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 6 0 6 6
1031 6 my($year,$month,$day,$hour,$min,$sec) = @_;
1032 6 my($seconds);
1033 6 ▶ if (DateCalc_date2time(\$seconds, $year,$month,$day, $hour,$min,$sec))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_date2time(\$seconds, $year, $month, $day, $hour, $min, $sec)) { } 6 0 6
1034 {
1035 6 return $seconds;
1036 }
1037 0 else { DATECALC_DATE_RANGE_ERROR('Date_to_Time'); }
1038 }
1039  
1040 sub Time_to_Date
1041 8 ▶{
Subroutine Time_to_Date: called CC=7 SCAR=21.8
Pod undocumented
1042 8 ▶ DATECALC_USAGE('Time_to_Date([time])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 8 8
Condition66%2/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
260
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table66%2/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
1043 8 my($seconds,$year,$month,$day,$hour,$min,$sec);
1044 8 ▶ if (@_ == 1) { $seconds = shift; }
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 6 2 8
1045 2 else { $seconds = time; }
1046 0 ▶ if (($seconds < 0) or ($seconds > 0xFFFFFFFF)) { DATECALC_TIME_RANGE_ERROR('Time_to_Date'); }
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds < 0 or $seconds > 4294967295) 0 8 8
Condition33%1/3
$seconds < 0 or $seconds > 4294967295
l!l&&r!l&&!r
008
MC/DC0%0/2
$seconds < 0 or $seconds > 4294967295
$seconds < 0 $seconds > 4294967295
Truth table33%1/3
A or B
A= $seconds < 0B= $seconds > 4294967295
ABresult
1X1
011
000
1047 8 ▶ if (DateCalc_time2date(\$year,\$month,\$day, \$hour,\$min,\$sec, $seconds))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_time2date(\$year, \$month, \$day, \$hour, \$min, \$sec, $seconds)) { } 8 0 8
1048 {
1049 8 return($year,$month,$day,$hour,$min,$sec);
1050 }
1051 0 else { DATECALC_TIME_RANGE_ERROR('Time_to_Date'); }
1052 }
1053  
1054 sub Easter_Sunday
1055 910 ▶{
Subroutine Easter_Sunday: called CC=4 SCAR=14.0
Pod undocumented
1056 910 ▶ DATECALC_USAGE('Easter_Sunday($year)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 910 910
1057 910 my($year) = shift;
1058 910 my($month,$day);
1059 910 ▶ if (($year > 0) and DateCalc_easter_sunday(\$year,\$month,\$day))
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 0 and DateCalc_easter_sunday(\$year, \$month, \$day)) { } 908 2 910
Condition66%2/3
$year > 0 and DateCalc_easter_sunday(\$year, \$month, \$day)
!ll&&!rl&&r
02908
MC/DC50%1/2
$year > 0 and DateCalc_easter_sunday(\$year, \$month, \$day)
$year > 0 DateCalc_easter_sunday(\$year, \$month, \$day)
Truth table66%2/3
A and B
A= $year > 0B= DateCalc_easter_sunday(\$year, \$month, \$day)
ABresult
0X0
100
111
1060 {
1061 908 return($year,$month,$day);
1062 }
1063 2 else { DATECALC_YEAR_ERROR('Easter_Sunday'); }
1064 }
1065  
1066 sub Decode_Month
1067 2109 ▶{
Subroutine Decode_Month: called CC=4 SCAR=14.1
Pod undocumented
1068 2109 ▶ DATECALC_USAGE('Decode_Month($string[,$lang])') unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 2109 2109
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
89912100
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1069 2109 my($string) = shift;
1070 2109 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
1209900
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1071 2109 return DateCalc_Decode_Month($string,$lang);
1072 }
1073  
1074 sub Decode_Day_of_Week
1075 1187 ▶{
Subroutine Decode_Day_of_Week: called CC=4 SCAR=14.1
Pod undocumented
1076 1187 ▶ DATECALC_USAGE('Decode_Day_of_Week($string[,$lang])') unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 1187 1187
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
3411530
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1077 1187 my($string) = shift;
1078 1187 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
115235
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1079 1187 return DateCalc_Decode_Day_of_Week($string,$lang);
1080 }
1081  
1082 sub Decode_Language
1083 10 ▶{
Subroutine Decode_Language: called CC=2 SCAR=7.1
Pod undocumented
1084 10 ▶ DATECALC_USAGE('Decode_Language($string)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 10 10
1085 10 my($string) = shift;
1086 10 return DateCalc_Decode_Language($string);
1087 }
1088  
1089 sub Decode_Date_EU
1090 14 ▶{
Subroutine Decode_Date_EU: called CC=5 SCAR=16.2
Pod undocumented
1091 14 ▶ DATECALC_USAGE('Decode_Date_EU($string[,$lang])') unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 14 14
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
1040
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1092 14 my($string) = shift;
1093 14 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
311
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1094 14 my($year,$month,$day);
1095 14 ▶ if (DateCalc_decode_date_eu($string,\$year,\$month,\$day,$lang))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_decode_date_eu($string, \$year, \$month, \$day, $lang)) { } 13 1 14
1096 {
1097 13 return($year,$month,$day);
1098 }
1099 1 else { return(); }
1100 }
1101  
1102 sub Decode_Date_US
1103 11 ▶{
Subroutine Decode_Date_US: called CC=5 SCAR=16.8
Pod undocumented
1104 11 ▶ DATECALC_USAGE('Decode_Date_US($string[,$lang])') unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 11 11
Condition33%1/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
1100
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table33%1/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1105 11 my($string) = shift;
1106 11 ▶ my($lang) = shift || 0;
Condition50%1/2
shift() || 0
l!l
011
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1107 11 my($year,$month,$day);
1108 11 ▶ if (DateCalc_decode_date_us($string,\$year,\$month,\$day,$lang))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_decode_date_us($string, \$year, \$month, \$day, $lang)) { } 10 1 11
1109 {
1110 10 return($year,$month,$day);
1111 }
1112 1 else { return(); }
1113 }
1114  
1115 sub Fixed_Window
1116 0 ▶{
Subroutine Fixed_Window: not called CC=2 SCAR=17.9
Pod undocumented
1117 0 ▶ DATECALC_USAGE('Fixed_Window($year)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
1118 0 my($year) = shift;
1119 0 return DateCalc_Fixed_Window($year);
1120 }
1121  
1122 sub Moving_Window
1123 84 ▶{
Subroutine Moving_Window: called CC=2 SCAR=7.1
Pod undocumented
1124 84 ▶ DATECALC_USAGE('Moving_Window($year)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 84 84
1125 84 my($year) = shift;
1126 84 return DateCalc_Moving_Window($year);
1127 }
1128  
1129 sub Compress
1130 6 ▶{
Subroutine Compress: called CC=2 SCAR=7.1
Pod undocumented
1131 6 ▶ DATECALC_USAGE('Compress($year,$month,$day)') unless (@_ == 3);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 0 6 6
1132 6 my($year,$month,$day) = @_;
1133 6 return DateCalc_Compress($year,$month,$day);
1134 }
1135  
1136 sub Uncompress
1137 5 ▶{
Subroutine Uncompress: called CC=3 SCAR=11.0
Pod undocumented
1138 5 ▶ DATECALC_USAGE('Uncompress($date)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 5 5
1139 5 my($date) = shift;
1140 5 my($century,$year,$month,$day);
1141 5 ▶ if (DateCalc_uncompress($date,\$century,\$year,\$month,\$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_uncompress($date, \$century, \$year, \$month, \$day)) { } 3 2 5
1142 {
1143 3 return($century,$year,$month,$day);
1144 }
1145 2 else { return(); }
1146 }
1147  
1148 sub check_compressed
1149 5 ▶{
Subroutine check_compressed: called CC=2 SCAR=7.1
Pod undocumented
1150 5 ▶ DATECALC_USAGE('check_compressed($date)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 5 5
1151 5 my($date) = shift;
1152 5 return DateCalc_check_compressed($date);
1153 }
1154  
1155 sub Compressed_to_Text
1156 20 ▶{
Subroutine Compressed_to_Text: called CC=4 SCAR=14.1
Pod undocumented
1157 20 ▶ DATECALC_USAGE('Compressed_to_Text($date[,$lang])') unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 20 20
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
5150
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1158 20 my($date) = shift;
1159 20 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
1010
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1160 20 return DateCalc_Compressed_to_Text($date,$lang);
1161 }
1162  
1163 sub Date_to_Text
1164 9 ▶{
Subroutine Date_to_Text: called CC=5 SCAR=16.7
Pod undocumented
1165 9 ▶ DATECALC_USAGE('Date_to_Text($year,$month,$day[,$lang])') unless ((@_ == 3) or (@_ == 4));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 or @_ == 4 0 9 9
Condition66%2/3
@_ == 3 or @_ == 4
l!l&&r!l&&!r
270
MC/DC0%0/2
@_ == 3 or @_ == 4
@_ == 3 @_ == 4
Truth table66%2/3
A or B
A= @_ == 3B= @_ == 4
ABresult
1X1
011
000
1166 9 my($year) = shift;
1167 9 my($month) = shift;
1168 9 my($day) = shift;
1169 9 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
54
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1170 9 ▶ if (DateCalc_check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year, $month, $day)) { } 9 0 9
1171 {
1172 9 return DateCalc_Date_to_Text($year,$month,$day,$lang);
1173 }
1174 0 else { DATECALC_DATE_ERROR('Date_to_Text'); }
1175 }
1176  
1177 sub Date_to_Text_Long
1178 55 ▶{
Subroutine Date_to_Text_Long: called CC=5 SCAR=16.7
Pod undocumented
1179 55 ▶ DATECALC_USAGE('Date_to_Text_Long($year,$month,$day[,$lang])') unless ((@_ == 3) or (@_ == 4));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 3 or @_ == 4 0 55 55
Condition66%2/3
@_ == 3 or @_ == 4
l!l&&r!l&&!r
15400
MC/DC0%0/2
@_ == 3 or @_ == 4
@_ == 3 @_ == 4
Truth table66%2/3
A or B
A= @_ == 3B= @_ == 4
ABresult
1X1
011
000
1180 55 my($year) = shift;
1181 55 my($month) = shift;
1182 55 my($day) = shift;
1183 55 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
3520
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1184 55 ▶ if (DateCalc_check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year, $month, $day)) { } 55 0 55
1185 {
1186 55 return DateCalc_Date_to_Text_Long($year,$month,$day,$lang);
1187 }
1188 0 else { DATECALC_DATE_ERROR('Date_to_Text_Long'); }
1189 }
1190  
1191 sub English_Ordinal
1192 0 ▶{
Subroutine English_Ordinal: not called CC=2 SCAR=17.9
Pod undocumented
1193 0 ▶ DATECALC_USAGE('English_Ordinal($number)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
1194 0 my($number) = shift;
1195 0 return DateCalc_English_Ordinal($number);
1196 }
1197  
1198 sub Calendar
1199 24 ▶{
Subroutine Calendar: called CC=8 SCAR=26.8
Pod undocumented
1200 24 ▶ DATECALC_USAGE('Calendar($year,$month[,$orthodox[,$lang]])') if ((@_ < 2) or (@_ > 4));
Branch: 1 branch
BranchTrueFalseTotal
if @_ < 2 or @_ > 4 0 24 24
Condition33%1/3
@_ < 2 or @_ > 4
l!l&&r!l&&!r
0024
MC/DC0%0/2
@_ < 2 or @_ > 4
@_ < 2 @_ > 4
Truth table33%1/3
A or B
A= @_ < 2B= @_ > 4
ABresult
1X1
011
000
1201 24 my($year) = shift;
1202 24 my($month) = shift;
1203 24 my($orthodox,$lang);
1204 0 ▶ if (@_ == 2) { $orthodox = shift; $lang = shift; }
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 2) { } 0 24 24
elsif (@_ == 1) { } 24 0 24
1205 24 elsif (@_ == 1) { $orthodox = shift; $lang = 0; }
1206 0 else { $orthodox = 0; $lang = 0; }
1207 24 ▶ if ($year > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($year > 0) { } 24 0 24
1208 {
1209 24 ▶ if (($month >= 1) and ($month <= 12))
Branch: 1 branch
BranchTrueFalseTotal
if ($month >= 1 and $month <= 12) { } 24 0 24
Condition33%1/3
$month >= 1 and $month <= 12
!ll&&!rl&&r
0024
MC/DC0%0/2
$month >= 1 and $month <= 12
$month >= 1 $month <= 12
Truth table33%1/3
A and B
A= $month >= 1B= $month <= 12
ABresult
0X0
100
111
1210 {
1211 24 return DateCalc_Calendar($year,$month,$orthodox,$lang);
1212 }
1213 0 else { DATECALC_MONTH_ERROR('Calendar'); }
1214 }
1215 0 else { DATECALC_YEAR_ERROR('Calendar'); }
1216 }
1217  
1218 sub Month_to_Text
1219 134 ▶{
Subroutine Month_to_Text: called CC=8 SCAR=20.9
Pod undocumented
1220 134 ▶ DATECALC_USAGE('Month_to_Text($month[,$lang])') unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 134 134
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
251090
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1221 134 my($month) = shift;
1222 134 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
9638
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1223 134 ▶ if (($lang < 1) or ($lang > $DateCalc_LANGUAGES)) { $lang = $DateCalc_Language; }
Branch: 1 branch
BranchTrueFalseTotal
if ($lang < 1 or $lang > $DateCalc_LANGUAGES) 38 96 134
Condition66%2/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
38096
MC/DC50%1/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table66%2/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
1224 134 ▶ if (($month >= 1) and ($month <= 12))
Branch: 1 branch
BranchTrueFalseTotal
if ($month >= 1 and $month <= 12) { } 119 15 134
Condition100%3/3
$month >= 1 and $month <= 12
!ll&&!rl&&r
114119
MC/DC100%2/2
$month >= 1 and $month <= 12
$month >= 1 $month <= 12
Truth table100%3/3
A and B
A= $month >= 1B= $month <= 12
ABresult
0X0
100
111
1225 {
1226 119 return $DateCalc_Month_to_Text_[$lang][$month];
1227 }
1228 15 else { DATECALC_MONTH_ERROR('Month_to_Text'); }
1229 }
1230  
1231 sub Day_of_Week_to_Text
1232 48 ▶{
Subroutine Day_of_Week_to_Text: called CC=8 SCAR=20.9
Pod undocumented
1233 48 ▶ DATECALC_USAGE('Day_of_Week_to_Text($dow[,$lang])') unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 48 48
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
25230
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1234 48 my($dow) = shift;
1235 48 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
1533
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1236 48 ▶ if (($lang < 1) or ($lang > $DateCalc_LANGUAGES)) { $lang = $DateCalc_Language; }
Branch: 1 branch
BranchTrueFalseTotal
if ($lang < 1 or $lang > $DateCalc_LANGUAGES) 33 15 48
Condition66%2/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
33015
MC/DC50%1/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table66%2/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
1237 48 ▶ if (($dow >= 1) and ($dow <= 7))
Branch: 1 branch
BranchTrueFalseTotal
if ($dow >= 1 and $dow <= 7) { } 38 10 48
Condition100%3/3
$dow >= 1 and $dow <= 7
!ll&&!rl&&r
1938
MC/DC100%2/2
$dow >= 1 and $dow <= 7
$dow >= 1 $dow <= 7
Truth table100%3/3
A and B
A= $dow >= 1B= $dow <= 7
ABresult
0X0
100
111
1238 {
1239 38 return $DateCalc_Day_of_Week_to_Text_[$lang][$dow];
1240 }
1241 10 else { DATECALC_DAYOFWEEK_ERROR('Day_of_Week_to_Text'); }
1242 }
1243  
1244 sub Day_of_Week_Abbreviation
1245 0 ▶{
Subroutine Day_of_Week_Abbreviation: not called CC=9 SCAR=45.0
Pod undocumented
1246 0 ▶ DATECALC_USAGE('Day_of_Week_Abbreviation($dow[,$lang])') unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 0 0
Condition0%0/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table0%0/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
1247 0 my($dow) = shift;
1248 0 ▶ my($lang) = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
1249 0 ▶ if (($lang < 1) or ($lang > $DateCalc_LANGUAGES)) { $lang = $DateCalc_Language; }
Branch: 1 branch
BranchTrueFalseTotal
if ($lang < 1 or $lang > $DateCalc_LANGUAGES) 0 0 0
Condition0%0/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
000
MC/DC0%0/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table0%0/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
1250 0 ▶ if (($dow >= 1) and ($dow <= 7))
Branch: 1 branch
BranchTrueFalseTotal
if ($dow >= 1 and $dow <= 7) { } 0 0 0
Condition0%0/3
$dow >= 1 and $dow <= 7
!ll&&!rl&&r
000
MC/DC0%0/2
$dow >= 1 and $dow <= 7
$dow >= 1 $dow <= 7
Truth table0%0/3
A and B
A= $dow >= 1B= $dow <= 7
ABresult
0X0
100
111
1251 {
1252 0 ▶ if ($DateCalc_Day_of_Week_Abbreviation_[$lang][0] ne '')
Branch: 1 branch
BranchTrueFalseTotal
if ($DateCalc_Day_of_Week_Abbreviation_[$lang][0] ne '') { } 0 0 0
1253 {
1254 0 return $DateCalc_Day_of_Week_Abbreviation_[$lang][$dow];
1255 }
1256 else
1257 {
1258 0 return substr($DateCalc_Day_of_Week_to_Text_[$lang][$dow],0,3);
1259 }
1260 }
1261 0 else { DATECALC_DAYOFWEEK_ERROR('Day_of_Week_Abbreviation'); }
1262 }
1263  
1264 sub Language_to_Text
1265 20 ▶{
Subroutine Language_to_Text: called CC=4 SCAR=14.0
Pod undocumented
1266 20 ▶ DATECALC_USAGE('Language_to_Text($lang)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 20 20
1267 20 my($lang) = shift;
1268 20 ▶ if (($lang >= 1) and ($lang <= $DateCalc_LANGUAGES))
Branch: 1 branch
BranchTrueFalseTotal
if ($lang >= 1 and $lang <= $DateCalc_LANGUAGES) { } 19 1 20
Condition66%2/3
$lang >= 1 and $lang <= $DateCalc_LANGUAGES
!ll&&!rl&&r
1019
MC/DC50%1/2
$lang >= 1 and $lang <= $DateCalc_LANGUAGES
$lang >= 1 $lang <= $DateCalc_LANGUAGES
Truth table66%2/3
A and B
A= $lang >= 1B= $lang <= $DateCalc_LANGUAGES
ABresult
0X0
100
111
1269 {
1270 19 return $DateCalc_Language_to_Text_[$lang];
1271 }
1272 1 else { DATECALC_LANGUAGE_ERROR('Language_to_Text'); }
1273 }
1274  
1275 sub Language
1276 425 ▶{
Subroutine Language: called CC=7 SCAR=21.3
Pod undocumented
1277 425 ▶ DATECALC_USAGE('Language([$lang])') unless ((@_ == 0) or (@_ == 1));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 or @_ == 1 0 425 425
Condition66%2/3
@_ == 0 or @_ == 1
l!l&&r!l&&!r
41960
MC/DC0%0/2
@_ == 0 or @_ == 1
@_ == 0 @_ == 1
Truth table66%2/3
A or B
A= @_ == 0B= @_ == 1
ABresult
1X1
011
000
1278 425 my($retval) = $DateCalc_Language;
1279 425 my($lang);
1280 425 ▶ if (@_ == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) 6 419 425
1281 {
1282 6 ▶ $lang = shift || 0;
Condition50%1/2
shift() || 0
l!l
60
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1283 6 ▶ if (($lang >= 1) and ($lang <= $DateCalc_LANGUAGES))
Branch: 1 branch
BranchTrueFalseTotal
if ($lang >= 1 and $lang <= $DateCalc_LANGUAGES) { } 6 0 6
Condition33%1/3
$lang >= 1 and $lang <= $DateCalc_LANGUAGES
!ll&&!rl&&r
006
MC/DC0%0/2
$lang >= 1 and $lang <= $DateCalc_LANGUAGES
$lang >= 1 $lang <= $DateCalc_LANGUAGES
Truth table33%1/3
A and B
A= $lang >= 1B= $lang <= $DateCalc_LANGUAGES
ABresult
0X0
100
111
1284 {
1285 6 $DateCalc_Language = $lang;
1286 }
1287 0 else { DATECALC_LANGUAGE_ERROR('Language'); }
1288 }
1289 425 return $retval;
1290 }
1291  
1292 sub Languages
1293 169 ▶{
Subroutine Languages: called CC=2 SCAR=7.2
Pod undocumented
1294 169 ▶ DATECALC_USAGE('Languages()') unless (@_ == 0);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 0 0 169 169
1295 169 return $DateCalc_LANGUAGES;
1296 }
1297  
1298 sub ISO_LC
1299 0 ▶{
Subroutine ISO_LC: not called CC=2 SCAR=17.9
Pod undocumented
1300 0 ▶ DATECALC_USAGE('ISO_LC($string)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 0 0
1301 0 my($string) = shift;
1302 0 $string =~ s!([\x41-\x5A\xC0-\xD6\xD8-\xDE])!chr(ord($1)+0x20)!ge;
1303 0 return $string;
1304 }
1305  
1306 sub ISO_UC
1307 253 ▶{
Subroutine ISO_UC: called CC=2 SCAR=7.0
Pod undocumented
1308 253 ▶ DATECALC_USAGE('ISO_UC($string)') unless (@_ == 1);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 0 253 253
1309 253 my($string) = shift;
1310 253 $string =~ s!([\x61-\x7A\xE0-\xF6\xF8-\xFE])!chr(ord($1)-0x20)!ge;
1311 253 return $string;
1312 }
1313  
1314 ##################
1315 ## ##
1316 ## DateCalc.c ##
1317 ## ##
1318 ##################
1319  
1320 ########################
1321 ## Private functions: ##
1322 ########################
1323  
1324 sub DateCalc_is_digit
1325 240 ▶{
Subroutine DateCalc_is_digit: called CC=2 SCAR=6.9
Pod undocumented
1326 240 ▶ return 1 if ($_[0] =~ /^[0-9]+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /^[0-9]+$/ 136 104 240
1327 104 return 0;
1328 }
1329  
1330 sub DateCalc_is_alnum
1331 122 ▶{
Subroutine DateCalc_is_alnum: called CC=2 SCAR=6.9
Pod undocumented
1332 122 ▶ return 1 if ($_[0] =~ /^[\x30-\x39\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF]+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /^[\x30-\x39\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF]+$/ 88 34 122
1333 34 return 0;
1334 }
1335  
1336 sub DateCalc_ISO_LC
1337 0 ▶{
Subroutine DateCalc_ISO_LC: not called CC=1 SCAR=6.9
Pod undocumented
1338 0 my($char) = $_[0];
1339 0 $char =~ s!([\x41-\x5A\xC0-\xD6\xD8-\xDE])!chr(ord($1)+0x20)!ge;
1340 0 return $char;
1341 }
1342  
1343 sub DateCalc_ISO_UC
1344 36967 ▶{
Subroutine DateCalc_ISO_UC: called CC=1 SCAR=0.0
Pod undocumented
1345 36967 my($char) = $_[0];
1346 36967 $char =~ s!([\x61-\x7A\xE0-\xF6\xF8-\xFE])!chr(ord($1)-0x20)!ge;
1347 36967 return $char;
1348 }
1349  
1350 sub DateCalc_ISO_UC_First
1351 24 ▶{
Subroutine DateCalc_ISO_UC_First: called CC=1 SCAR=0.0
Pod undocumented
1352 24 my($string) = $_[0];
1353 24 $string =~ s!([\x41-\x5A\xC0-\xD6\xD8-\xDE])!chr(ord($1)+0x20)!ge;
1354 24 $string =~ s!^([\x61-\x7A\xE0-\xF6\xF8-\xFE])!chr(ord($1)-0x20)!e;
1355 24 return $string;
1356 }
1357  
1358 sub DateCalc_Year_to_Days
1359 41799 ▶{
Subroutine DateCalc_Year_to_Days: called CC=1 SCAR=0.0
Pod undocumented
1360 41799 my($year) = $_[0];
1361 41799 my($days) = $year * 365;
1362 41799 $year >>= 2;
1363 41799 $days += $year;
1364 41799 $year = int($year / 25);
1365 41799 $days -= $year;
1366 41799 $days += ($year >> 2);
1367 41799 return $days;
1368 }
1369  
1370 sub DateCalc_scan9
1371 251 ▶{ ## Mnemonic: COBOL "PIC 9" ##
Subroutine DateCalc_scan9: called CC=3 SCAR=11.0
Pod undocumented
1372 251 my($str,$buf,$len,$idx,$neg) = @_;
1373 251 $idx += $buf;
1374 251 $len += $buf;
1375 251 ▶ if (($idx >= 0) and ($idx < $len)) { return DateCalc_is_digit(substr($str,$idx,1)) ^ $neg; }
Branch: 1 branch
BranchTrueFalseTotal
if ($idx >= 0 and $idx < $len) 240 11 251
Condition100%3/3
$idx >= 0 and $idx < $len
!ll&&!rl&&r
38240
MC/DC100%2/2
$idx >= 0 and $idx < $len
$idx >= 0 $idx < $len
Truth table100%3/3
A and B
A= $idx >= 0B= $idx < $len
ABresult
0X0
100
111
1376 11 return 0;
1377 }
1378  
1379 sub DateCalc_scanx
1380 138 ▶{ ## Mnemonic: COBOL "PIC X" ##
Subroutine DateCalc_scanx: called CC=3 SCAR=11.0
Pod undocumented
1381 138 my($str,$buf,$len,$idx,$neg) = @_;
1382 138 $idx += $buf;
1383 138 $len += $buf;
1384 138 ▶ if (($idx >= 0) and ($idx < $len)) { return DateCalc_is_alnum(substr($str,$idx,1)) ^ $neg; }
Branch: 1 branch
BranchTrueFalseTotal
if ($idx >= 0 and $idx < $len) 122 16 138
Condition66%2/3
$idx >= 0 and $idx < $len
!ll&&!rl&&r
016122
MC/DC50%1/2
$idx >= 0 and $idx < $len
$idx >= 0 $idx < $len
Truth table66%2/3
A and B
A= $idx >= 0B= $idx < $len
ABresult
0X0
100
111
1385 16 return 0;
1386 }
1387  
1388 sub DateCalc_Center
1389 24 ▶{
Subroutine DateCalc_Center: called CC=2 SCAR=6.9
Pod undocumented
1390 24 my($_target,$source,$width) = @_;
1391 24 my($length,$blank);
1392 24 $length = length($source);
1393 24 ▶ $length = $width if ($length > $width);
Branch: 1 branch
BranchTrueFalseTotal
if $length > $width 0 24 24
1394 24 $blank = $width - $length;
1395 24 $blank >>= 1;
1396 24 $$_target .= ' ' x $blank;
1397 24 $$_target .= substr($source,0,$length);
1398 24 $$_target .= "\n";
1399 }
1400  
1401 sub DateCalc_Blank
1402 646 ▶{
Subroutine DateCalc_Blank: called CC=1 SCAR=0.0
Pod undocumented
1403 646 my($_target,$count) = @_;
1404 646 $$_target .= ' ' x $count;
1405 }
1406  
1407 sub DateCalc_Newline
1408 149 ▶{
Subroutine DateCalc_Newline: called CC=1 SCAR=0.0
Pod undocumented
1409 149 my($_target,$count) = @_;
1410 149 $$_target .= "\n" x $count;
1411 }
1412  
1413 sub DateCalc_Normalize_Time
1414 305 ▶{
Subroutine DateCalc_Normalize_Time: called CC=1 SCAR=0.0
Pod undocumented
1415 305 my($_Dd,$_Dh,$_Dm,$_Ds) = @_;
1416 305 my($quot);
1417 305 $quot = int($$_Ds / 60);
1418 305 $$_Ds -= $quot * 60;
1419 305 $$_Dm += $quot;
1420 305 $quot = int($$_Dm / 60);
1421 305 $$_Dm -= $quot * 60;
1422 305 $$_Dh += $quot;
1423 305 $quot = int($$_Dh / 24);
1424 305 $$_Dh -= $quot * 24;
1425 305 $$_Dd += $quot;
1426 }
1427  
1428 ## Prevent overflow errors on systems ##
1429 ## with short "long"s (e.g. 32 bits): ##
1430  
1431 sub DateCalc_Normalize_Ranges
1432 152 ▶{
Subroutine DateCalc_Normalize_Ranges: called CC=1 SCAR=0.0
Pod undocumented
1433 152 my($_Dd,$_Dh,$_Dm,$_Ds) = @_;
1434 152 my($quot);
1435 152 $quot = int($$_Dh / 24);
1436 152 $$_Dh -= $quot * 24;
1437 152 $$_Dd += $quot;
1438 152 $quot = int($$_Dm / 60);
1439 152 $$_Dm -= $quot * 60;
1440 152 $$_Dh += $quot;
1441 152 DateCalc_Normalize_Time($_Dd,$_Dh,$_Dm,$_Ds);
1442 }
1443  
1444 # $_Dh and $_Dm are assumed to be empty;
1445 # the whole time part must be in $_Ds:
1446  
1447 sub DateCalc_Normalize_Signs
1448 34 ▶{
Subroutine DateCalc_Normalize_Signs: called CC=6 SCAR=17.9
Pod undocumented
1449 34 my($_Dd,$_Dh,$_Dm,$_Ds) = @_;
1450 34 my($quot);
1451 34 $quot = int($$_Ds / 86400);
1452 34 $$_Ds -= $quot * 86400;
1453 34 $$_Dd += $quot;
1454 34 ▶ if ($$_Dd != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_Dd != 0) 31 3 34
1455 {
1456 31 ▶ if ($$_Dd > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_Dd > 0) { } 14 17 31
1457 {
1458 14 ▶ if ($$_Ds < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_Ds < 0) 7 7 14
1459 {
1460 7 $$_Ds += 86400;
1461 7 ${$_Dd}--;
1462 }
1463 }
1464 else
1465 {
1466 17 ▶ if ($$_Ds > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_Ds > 0) 5 12 17
1467 {
1468 5 $$_Ds -= 86400;
1469 5 ${$_Dd}++;
1470 }
1471 }
1472 }
1473 34 $$_Dh = 0;
1474 34 $$_Dm = 0;
1475 34 ▶ if ($$_Ds != 0) { DateCalc_Normalize_Time($_Dd,$_Dh,$_Dm,$_Ds); }
Branch: 1 branch
BranchTrueFalseTotal
if ($$_Ds != 0) 34 0 34
1476 }
1477  
1478 sub DateCalc_Normalize_DHMS
1479 14 ▶{
Subroutine DateCalc_Normalize_DHMS: called CC=1 SCAR=0.0
Pod undocumented
1480 14 my($_Dd,$_Dh,$_Dm,$_Ds) = @_;
1481 14 DateCalc_Normalize_Ranges($_Dd,$_Dh,$_Dm,$_Ds);
1482 14 $$_Ds += (($$_Dh * 60) + $$_Dm) * 60;
1483 14 DateCalc_Normalize_Signs($_Dd,$_Dh,$_Dm,$_Ds);
1484 }
1485  
1486 #######################
1487 ## Public functions: ##
1488 #######################
1489  
1490 sub DateCalc_leap_year
1491 91840 ▶{
Subroutine DateCalc_leap_year: called CC=3 SCAR=11.0
Pod undocumented
1492 91840 my($year) = $_[0];
1493 91840 my($yy);
1494 91840 ▶ return( (($year & 0x03) == 0) and
Condition100%6/6
($year & 3) == 0 && (($yy = int $year / 100) * 100 != $year || ($yy & 3) == 0)
!ll&&!rl&&r
107511581074
($yy = int $year / 100) * 100 != $year or ($yy & 3) == 0
l!l&&r!l&&!r
39367713815
MC/DC100%3/3
($year & 3) == 0 && (($yy = int $year / 100) * 100 != $year || ($yy & 3) == 0)
($year & 3) == 0 ($yy = int $year / 100) * 100 != $year ($yy & 3) == 0
Truth table100%4/4
A && B or C
A= ($year & 3) == 0B= ($yy = int $year / 100) * 100 != $yearC= ($yy & 3) == 0
ABCresult
0XX0
1000
11X1
1011
1495 ( ((($yy = int($year / 100)) * 100) != $year) or
1496 (($yy & 0x03) == 0) ) );
1497 }
1498  
1499 sub DateCalc_check_date
1500 49407 ▶{
Subroutine DateCalc_check_date: called CC=6 SCAR=17.9
Pod undocumented
1501 49407 my($year,$month,$day) = @_;
1502 49407 ▶ return 1 if
Branch: 1 branch
BranchTrueFalseTotal
if $year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[DateCalc_leap_year($year)][$month] 49360 47 49407
Condition91%11/12
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[DateCalc_leap_year($year)][$month]
!ll&&!rl&&r
192849360
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1
!ll&&!rl&&r
14549388
$year >= 1 and $month >= 1 and $month <= 12
!ll&&!rl&&r
14049393
$year >= 1 and $month >= 1
!ll&&!rl&&r
7749393
MC/DC80%4/5
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[DateCalc_leap_year($year)][$month]
$year >= 1 $month >= 1 $month <= 12 $day >= 1 $day <= $DateCalc_Days_in_Month_[DateCalc_leap_year($year)][$month]
Truth table83%5/6
A and B and C and D and E
A= $year >= 1B= $month >= 1C= $month <= 12D= $day >= 1E= $day <= $DateCalc_Days_in_Month_[DateCalc_leap_year($year)][$month]
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1503 (($year >= 1) and
1504 ($month >= 1) and ($month <= 12) and
1505 ($day >= 1) and
1506 ($day <= $DateCalc_Days_in_Month_[DateCalc_leap_year($year)][$month]));
1507 47 return 0;
1508 }
1509  
1510 sub DateCalc_check_time
1511 1021 ▶{
Subroutine DateCalc_check_time: called CC=7 SCAR=19.5
Pod undocumented
1512 1021 my($hour,$min,$sec) = @_;
1513 1021 ▶ return 1 if
Branch: 1 branch
BranchTrueFalseTotal
if $hour >= 0 and $min >= 0 and $sec >= 0 and $hour < 24 and $min < 60 and $sec < 60 1004 17 1021
Condition100%15/15
$hour >= 0 and $min >= 0 and $sec >= 0 and $hour < 24 and $min < 60 and $sec < 60
!ll&&!rl&&r
1431004
$hour >= 0 and $min >= 0 and $sec >= 0 and $hour < 24 and $min < 60
!ll&&!rl&&r
1041007
$hour >= 0 and $min >= 0 and $sec >= 0 and $hour < 24
!ll&&!rl&&r
641011
$hour >= 0 and $min >= 0 and $sec >= 0
!ll&&!rl&&r
421015
$hour >= 0 and $min >= 0
!ll&&!rl&&r
221017
MC/DC100%6/6
$hour >= 0 and $min >= 0 and $sec >= 0 and $hour < 24 and $min < 60 and $sec < 60
$hour >= 0 $min >= 0 $sec >= 0 $hour < 24 $min < 60 $sec < 60
Truth table100%7/7
A and B and C and D and E and F
A= $hour >= 0B= $min >= 0C= $sec >= 0D= $hour < 24E= $min < 60F= $sec < 60
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
1514 (($hour >= 0) and ($min >= 0) and ($sec >= 0) and
1515 ($hour < 24) and ($min < 60) and ($sec < 60));
1516 17 return 0;
1517 }
1518  
1519 sub DateCalc_check_business_date
1520 629 ▶{
Subroutine DateCalc_check_business_date: called CC=6 SCAR=25.9
Pod undocumented
1521 629 my($year,$week,$dow) = @_;
1522 629 ▶ return 1 if
Branch: 1 branch
BranchTrueFalseTotal
if $year >= 1 and $week >= 1 and $week <= DateCalc_Weeks_in_Year($year) and $dow >= 1 and $dow <= 7 629 0 629
Condition33%4/12
$year >= 1 and $week >= 1 and $week <= DateCalc_Weeks_in_Year($year) and $dow >= 1 and $dow <= 7
!ll&&!rl&&r
00629
$year >= 1 and $week >= 1 and $week <= DateCalc_Weeks_in_Year($year) and $dow >= 1
!ll&&!rl&&r
00629
$year >= 1 and $week >= 1 and $week <= DateCalc_Weeks_in_Year($year)
!ll&&!rl&&r
00629
$year >= 1 and $week >= 1
!ll&&!rl&&r
00629
MC/DC0%0/5
$year >= 1 and $week >= 1 and $week <= DateCalc_Weeks_in_Year($year) and $dow >= 1 and $dow <= 7
$year >= 1 $week >= 1 $week <= DateCalc_Weeks_in_Year($year) $dow >= 1 $dow <= 7
Truth table16%1/6
A and B and C and D and E
A= $year >= 1B= $week >= 1C= $week <= DateCalc_Weeks_in_Year($year)D= $dow >= 1E= $dow <= 7
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1523 (($year >= 1) and
1524 ($week >= 1) and ($week <= DateCalc_Weeks_in_Year($year)) and
1525 ($dow >= 1) and ($dow <= 7));
1526 0 return 0;
1527 }
1528  
1529 sub DateCalc_Day_of_Year
1530 0 ▶{
Subroutine DateCalc_Day_of_Year: not called CC=6 SCAR=37.4
Pod undocumented
1531 0 my($year,$month,$day) = @_;
1532 0 my($leap);
1533 0 ▶ if (($year >= 1) and
Branch: 1 branch
BranchTrueFalseTotal
if ($year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]) 0 0 0
Condition0%0/12
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]
!ll&&!rl&&r
000
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1
!ll&&!rl&&r
000
$year >= 1 and $month >= 1 and $month <= 12
!ll&&!rl&&r
000
$year >= 1 and $month >= 1
!ll&&!rl&&r
000
MC/DC0%0/5
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]
$year >= 1 $month >= 1 $month <= 12 $day >= 1 $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]
Truth table0%0/6
A and B and C and D and E
A= $year >= 1B= $month >= 1C= $month <= 12D= $day >= 1E= $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1534 ($month >= 1) and ($month <= 12) and
1535 ($day >= 1) and
1536 ($day <= $DateCalc_Days_in_Month_[($leap=DateCalc_leap_year($year))][$month]))
1537 {
1538 0 return $DateCalc_Days_in_Year_[$leap][$month] + $day;
1539 }
1540 0 return 0;
1541 }
1542  
1543 sub DateCalc_Date_to_Days
1544 37448 ▶{
Subroutine DateCalc_Date_to_Days: called CC=6 SCAR=18.2
Pod undocumented
1545 37448 my($year,$month,$day) = @_;
1546 37448 my($leap);
1547 37448 ▶ if (($year >= 1) and
Branch: 1 branch
BranchTrueFalseTotal
if ($year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]) 37445 3 37448
Condition75%9/12
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]
!ll&&!rl&&r
1237445
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1
!ll&&!rl&&r
1037447
$year >= 1 and $month >= 1 and $month <= 12
!ll&&!rl&&r
1037447
$year >= 1 and $month >= 1
!ll&&!rl&&r
1037447
MC/DC40%2/5
$year >= 1 and $month >= 1 and $month <= 12 and $day >= 1 and $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]
$year >= 1 $month >= 1 $month <= 12 $day >= 1 $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]
Truth table50%3/6
A and B and C and D and E
A= $year >= 1B= $month >= 1C= $month <= 12D= $day >= 1E= $day <= $DateCalc_Days_in_Month_[$leap = DateCalc_leap_year($year)][$month]
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1548 ($month >= 1) and ($month <= 12) and
1549 ($day >= 1) and
1550 ($day <= $DateCalc_Days_in_Month_[($leap=DateCalc_leap_year($year))][$month]))
1551 {
1552 37445 return DateCalc_Year_to_Days(--$year)
1553 + $DateCalc_Days_in_Year_[$leap][$month]
1554 + $day;
1555 }
1556 3 return 0;
1557 }
1558  
1559 sub DateCalc_Day_of_Week
1560 6535 ▶{
Subroutine DateCalc_Day_of_Week: called CC=2 SCAR=6.9
Pod undocumented
1561 6535 my($year,$month,$day) = @_;
1562 6535 my($days);
1563 6535 $days = DateCalc_Date_to_Days($year,$month,$day);
1564 6535 ▶ if ($days > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($days > 0) 6534 1 6535
1565 {
1566 6534 $days--;
1567 6534 $days %= 7;
1568 6534 $days++;
1569 }
1570 6535 return $days;
1571 }
1572  
1573 sub DateCalc_Weeks_in_Year
1574 1282 ▶{
Subroutine DateCalc_Weeks_in_Year: called CC=3 SCAR=11.0
Pod undocumented
1575 1282 my($year) = $_[0];
1576 1282 ▶ if ((DateCalc_Day_of_Week($year,1,1) == 4) or
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_Day_of_Week($year, 1, 1) == 4 or DateCalc_Day_of_Week($year, 12, 31) == 4) { } 305 977 1282
Condition100%3/3
DateCalc_Day_of_Week($year, 1, 1) == 4 or DateCalc_Day_of_Week($year, 12, 31) == 4
l!l&&r!l&&!r
21590977
MC/DC100%2/2
DateCalc_Day_of_Week($year, 1, 1) == 4 or DateCalc_Day_of_Week($year, 12, 31) == 4
DateCalc_Day_of_Week($year, 1, 1) == 4 DateCalc_Day_of_Week($year, 12, 31) == 4
Truth table100%3/3
A or B
A= DateCalc_Day_of_Week($year, 1, 1) == 4B= DateCalc_Day_of_Week($year, 12, 31) == 4
ABresult
1X1
011
000
1577 (DateCalc_Day_of_Week($year,12,31) == 4))
1578 305 { return 53; }
1579 else
1580 977 { return 52; }
1581 }
1582  
1583 sub DateCalc_Week_Number
1584 636 ▶{
Subroutine DateCalc_Week_Number: called CC=2 SCAR=6.9
Pod undocumented
1585 636 my($year,$month,$day) = @_;
1586 636 my($first,$week);
1587 636 $first = DateCalc_Day_of_Week($year,1,1) - 1;
1588 636 $week = int((DateCalc_Delta_Days($year,1,1, $year,$month,$day) + $first) / 7);
1589 636 ▶ if ($first < 4) { return ++$week; }
Branch: 1 branch
BranchTrueFalseTotal
if ($first < 4) { } 351 285 636
1590 285 else { return $week; }
1591 }
1592  
1593 sub DateCalc_week_of_year
1594 638 ▶{
Subroutine DateCalc_week_of_year: called CC=4 SCAR=13.9
Pod undocumented
1595 638 my($_week,$_year,$month,$day) = @_;
1596 638 ▶ if (DateCalc_check_date($$_year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($$_year, $month, $day)) 636 2 638
1597 {
1598 636 $$_week = DateCalc_Week_Number($$_year,$month,$day);
1599 636 ▶ if ($$_week == 0) { $$_week = DateCalc_Weeks_in_Year(--${$_year}); }
Branch: 2 branches
BranchTrueFalseTotal
if ($$_week == 0) { } 37 599 636
elsif ($$_week > DateCalc_Weeks_in_Year($$_year)) { } 31 568 599
1600 elsif ($$_week > DateCalc_Weeks_in_Year($$_year))
1601 {
1602 31 $$_week = 1;
1603 31 ${$_year}++;
1604 }
1605 636 return 1;
1606 }
1607 2 return 0;
1608 }
1609  
1610 sub DateCalc_monday_of_week
1611 11 ▶{
Subroutine DateCalc_monday_of_week: called CC=2 SCAR=6.9
Pod undocumented
1612 11 my($week,$_year,$_month,$_day) = @_;
1613 11 my($first);
1614 11 $$_month = $$_day = 1;
1615 11 $first = DateCalc_Day_of_Week($$_year,1,1) - 1;
1616 11 ▶ $week-- if ($first < 4);
Branch: 1 branch
BranchTrueFalseTotal
if $first < 4 6 5 11
1617 11 return DateCalc_add_delta_days($_year,$_month,$_day, ($week * 7 - $first));
1618 }
1619  
1620 sub DateCalc_nth_weekday_of_month_year
1621 1323 ▶{
Subroutine DateCalc_nth_weekday_of_month_year: called CC=11 SCAR=28.4
Pod undocumented
1622 1323 my($_year,$_month,$_day,$dow,$n) = @_;
1623 1323 my($mm) = $$_month;
1624 1323 my($first,$delta);
1625 1323 $$_day = 1;
1626 1323 ▶ return 0 if
Branch: 1 branch
BranchTrueFalseTotal
if $$_year < 1 or $mm < 1 or $mm > 12 or $dow < 1 or $dow > 7 or $n < 1 or $n > 5 0 1323 1323
Condition33%6/18
$$_year < 1 or $mm < 1 or $mm > 12 or $dow < 1 or $dow > 7 or $n < 1 or $n > 5
l!l&&r!l&&!r
001323
$$_year < 1 or $mm < 1 or $mm > 12 or $dow < 1 or $dow > 7 or $n < 1
l!l&&r!l&&!r
001323
$$_year < 1 or $mm < 1 or $mm > 12 or $dow < 1 or $dow > 7
l!l&&r!l&&!r
001323
$$_year < 1 or $mm < 1 or $mm > 12 or $dow < 1
l!l&&r!l&&!r
001323
$$_year < 1 or $mm < 1 or $mm > 12
l!l&&r!l&&!r
001323
$$_year < 1 or $mm < 1
l!l&&r!l&&!r
001323
MC/DC0%0/7
$$_year < 1 or $mm < 1 or $mm > 12 or $dow < 1 or $dow > 7 or $n < 1 or $n > 5
$$_year < 1 $mm < 1 $mm > 12 $dow < 1 $dow > 7 $n < 1 $n > 5
Truth table12%1/8
A or B or C or D or E or F or G
A= $$_year < 1B= $mm < 1C= $mm > 12D= $dow < 1E= $dow > 7F= $n < 1G= $n > 5
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
1627 (($$_year < 1) or
1628 ($mm < 1) or ($mm > 12) or
1629 ($dow < 1) or ($dow > 7) or
1630 ($n < 1) or ($n > 5));
1631 1323 $first = DateCalc_Day_of_Week($$_year,$mm,1);
1632 1323 ▶ $dow += 7 if ($dow < $first);
Branch: 1 branch
BranchTrueFalseTotal
if $dow < $first 602 721 1323
1633 1323 $delta = $dow - $first;
1634 1323 $delta += --$n * 7;
1635 1323 ▶ return 1 if (DateCalc_add_delta_days($_year,$_month,$_day,$delta) and ($$_month == $mm));
Branch: 1 branch
BranchTrueFalseTotal
if DateCalc_add_delta_days($_year, $_month, $_day, $delta) and $$_month == $mm 1252 71 1323
Condition66%2/3
DateCalc_add_delta_days($_year, $_month, $_day, $delta) and $$_month == $mm
!ll&&!rl&&r
0711252
MC/DC50%1/2
DateCalc_add_delta_days($_year, $_month, $_day, $delta) and $$_month == $mm
DateCalc_add_delta_days($_year, $_month, $_day, $delta) $$_month == $mm
Truth table66%2/3
A and B
A= DateCalc_add_delta_days($_year, $_month, $_day, $delta)B= $$_month == $mm
ABresult
0X0
100
111
1636 71 return 0;
1637 }
1638  
1639 sub DateCalc_standard_to_business
1640 629 ▶{
Subroutine DateCalc_standard_to_business: called CC=2 SCAR=7.2
Pod undocumented
1641 629 my($_year,$_week,$_dow,$month,$day) = @_;
1642 629 my($yy) = $$_year;
1643  
1644 629 ▶ if (DateCalc_week_of_year($_week,$_year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_week_of_year($_week, $_year, $month, $day)) 629 0 629
1645 {
1646 629 $$_dow = DateCalc_Day_of_Week($yy,$month,$day);
1647 629 return 1;
1648 }
1649 0 return 0;
1650 }
1651  
1652 sub DateCalc_business_to_standard
1653 629 ▶{
Subroutine DateCalc_business_to_standard: called CC=3 SCAR=11.1
Pod undocumented
1654 629 my($_year,$_month,$_day,$week,$dow) = @_;
1655 629 my($first,$delta);
1656 629 ▶ if (DateCalc_check_business_date($$_year,$week,$dow))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_business_date($$_year, $week, $dow)) 629 0 629
1657 {
1658 629 $$_month = $$_day = 1;
1659 629 $first = DateCalc_Day_of_Week($$_year,1,1);
1660 629 ▶ $week++ if ($first > 4);
Branch: 1 branch
BranchTrueFalseTotal
if $first > 4 260 369 629
1661 629 $delta = --$week * 7 + $dow - $first;
1662 629 return DateCalc_add_delta_days($_year,$_month,$_day,$delta);
1663 }
1664 0 return 0;
1665 }
1666  
1667 sub DateCalc_Delta_Days
1668 665 ▶{
Subroutine DateCalc_Delta_Days: called CC=1 SCAR=0.0
Pod undocumented
1669 665 return DateCalc_Date_to_Days(@_[3..5]) -
1670 DateCalc_Date_to_Days(@_[0..2]);
1671 }
1672  
1673 sub DateCalc_delta_hms
1674 20 ▶{
Subroutine DateCalc_delta_hms: called CC=3 SCAR=12.3
Pod undocumented
1675 20 my($_Dd,$_Dh,$_Dm,$_Ds,$hour1,$min1,$sec1,$hour2,$min2,$sec2) = @_;
1676 20 ▶ if (DateCalc_check_time($hour1,$min1,$sec1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)) 20 0 20
Condition33%1/3
DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)
!ll&&!rl&&r
0020
MC/DC0%0/2
DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_time($hour2, $min2, $sec2)
DateCalc_check_time($hour1, $min1, $sec1) DateCalc_check_time($hour2, $min2, $sec2)
Truth table33%1/3
A and B
A= DateCalc_check_time($hour1, $min1, $sec1)B= DateCalc_check_time($hour2, $min2, $sec2)
ABresult
0X0
100
111
1677 DateCalc_check_time($hour2,$min2,$sec2))
1678 {
1679 20 $$_Ds = (((($hour2 * 60) + $min2) * 60) + $sec2) -
1680 (((($hour1 * 60) + $min1) * 60) + $sec1);
1681 20 DateCalc_Normalize_Signs($_Dd,$_Dh,$_Dm,$_Ds);
1682 20 return 1;
1683 }
1684 0 return 0;
1685 }
1686  
1687 sub DateCalc_delta_dhms
1688 17 ▶{
Subroutine DateCalc_delta_dhms: called CC=3 SCAR=12.3
Pod undocumented
1689 17 my($_Dd,$_Dh,$_Dm,$_Ds,$year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2) = @_;
1690 17 $$_Dd = $$_Dh = $$_Dm = $$_Ds = 0;
1691 17 ▶ if (DateCalc_check_date($year1,$month1,$day1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)) 17 0 17
Condition33%1/3
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
!ll&&!rl&&r
0017
MC/DC0%0/2
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_date($year2, $month2, $day2)
DateCalc_check_date($year1, $month1, $day1) DateCalc_check_date($year2, $month2, $day2)
Truth table33%1/3
A and B
A= DateCalc_check_date($year1, $month1, $day1)B= DateCalc_check_date($year2, $month2, $day2)
ABresult
0X0
100
111
1692 DateCalc_check_date($year2,$month2,$day2))
1693 {
1694 17 $$_Dd = DateCalc_Delta_Days($year1,$month1,$day1, $year2,$month2,$day2);
1695 17 return DateCalc_delta_hms($_Dd,$_Dh,$_Dm,$_Ds, $hour1,$min1,$sec1, $hour2,$min2,$sec2);
1696 }
1697 0 return 0;
1698 }
1699  
1700 sub DateCalc_delta_ymd
1701 8 ▶{
Subroutine DateCalc_delta_ymd: called CC=3 SCAR=12.0
Pod undocumented
1702 8 my($_year1,$_month1,$_day1,$year2,$month2,$day2) = @_;
1703 8 ▶ if (DateCalc_check_date($$_year1,$$_month1,$$_day1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($$_year1, $$_month1, $$_day1) and DateCalc_check_date($year2, $month2, $day2)) 8 0 8
Condition33%1/3
DateCalc_check_date($$_year1, $$_month1, $$_day1) and DateCalc_check_date($year2, $month2, $day2)
!ll&&!rl&&r
008
MC/DC0%0/2
DateCalc_check_date($$_year1, $$_month1, $$_day1) and DateCalc_check_date($year2, $month2, $day2)
DateCalc_check_date($$_year1, $$_month1, $$_day1) DateCalc_check_date($year2, $month2, $day2)
Truth table33%1/3
A and B
A= DateCalc_check_date($$_year1, $$_month1, $$_day1)B= DateCalc_check_date($year2, $month2, $day2)
ABresult
0X0
100
111
1704 DateCalc_check_date( $year2, $month2, $day2))
1705 {
1706 8 $$_day1 = $day2 - $$_day1;
1707 8 $$_month1 = $month2 - $$_month1;
1708 8 $$_year1 = $year2 - $$_year1;
1709 8 return 1;
1710 }
1711 0 return 0;
1712 }
1713  
1714 sub DateCalc_delta_ymdhms
1715 3 ▶{
Subroutine DateCalc_delta_ymdhms: called CC=3 SCAR=11.2
Pod undocumented
1716 3 my($_D_y,$_D_m,$_D_d,$_Dh,$_Dm,$_Ds,$year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2) = @_;
1717 3 ▶ return 0 unless (DateCalc_delta_ymd(\$year1,\$month1,\$day1, $year2,$month2,$day2));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_delta_ymd(\$year1, \$month1, \$day1, $year2, $month2, $day2) 0 3 3
1718 3 $$_D_d = $day1;
1719 3 ▶ return 0 unless (DateCalc_delta_hms($_D_d,$_Dh,$_Dm,$_Ds, $hour1,$min1,$sec1, $hour2,$min2,$sec2));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_delta_hms($_D_d, $_Dh, $_Dm, $_Ds, $hour1, $min1, $sec1, $hour2, $min2, $sec2) 0 3 3
1720 3 $$_D_y = $year1;
1721 3 $$_D_m = $month1;
1722 3 return 1;
1723 }
1724  
1725 sub DateCalc_norm_delta_ymd
1726 82 ▶{
Subroutine DateCalc_norm_delta_ymd: called CC=32 SCAR=34.7
Pod undocumented
1727 82 my($_year1,$_month1,$_day1,$year2,$month2,$day2) = @_;
1728 82 my($Dy) = 0;
1729 82 my($Dm) = 0;
1730 82 my($Dd) = 0;
1731 82 my($d2,$ty,$tm,$td);
1732  
1733 82 ▶ if (DateCalc_check_date($$_year1,$$_month1,$$_day1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($$_year1, $$_month1, $$_day1) and DateCalc_check_date($year2, $month2, $day2)) 74 8 82
Condition100%3/3
DateCalc_check_date($$_year1, $$_month1, $$_day1) and DateCalc_check_date($year2, $month2, $day2)
!ll&&!rl&&r
4474
MC/DC100%2/2
DateCalc_check_date($$_year1, $$_month1, $$_day1) and DateCalc_check_date($year2, $month2, $day2)
DateCalc_check_date($$_year1, $$_month1, $$_day1) DateCalc_check_date($year2, $month2, $day2)
Truth table100%3/3
A and B
A= DateCalc_check_date($$_year1, $$_month1, $$_day1)B= DateCalc_check_date($year2, $month2, $day2)
ABresult
0X0
100
111
1734 DateCalc_check_date( $year2, $month2, $day2))
1735 {
1736 74 $d2 = DateCalc_Date_to_Days( $year2, $month2, $day2);
1737 74 $Dd = $d2-DateCalc_Date_to_Days($$_year1,$$_month1,$$_day1);
1738 74 ▶ if (($Dd < -30) or ($Dd > 30))
Branch: 1 branch
BranchTrueFalseTotal
if ($Dd < -30 or $Dd > 30) 50 24 74
Condition100%3/3
$Dd < -30 or $Dd > 30
l!l&&r!l&&!r
242624
MC/DC100%2/2
$Dd < -30 or $Dd > 30
$Dd < -30 $Dd > 30
Truth table100%3/3
A or B
A= $Dd < -30B= $Dd > 30
ABresult
1X1
011
000
1739 {
1740 50 $Dy = ($year2 - $$_year1);
1741 50 $Dm = ($month2 - $$_month1);
1742 50 ▶ $ty=$$_year1; $tm=$$_month1; $td=$$_day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td);
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 50 50
1743 50 ▶ unless ((($Dy >= 0) and ($Dm >= 0) and ($Dd >= 0)) or
Branch: 1 branch
BranchTrueFalseTotal
unless ($Dy >= 0 and $Dm >= 0 and $Dd >= 0 or $Dy <= 0 and $Dm <= 0 and $Dd <= 0) 33 17 50
Condition100%15/15
$Dy >= 0 and $Dm >= 0 and $Dd >= 0 or $Dy <= 0 and $Dm <= 0 and $Dd <= 0
l!l&&r!l&&!r
10733
$Dy >= 0 and $Dm >= 0 and $Dd >= 0
!ll&&!rl&&r
31910
$Dy >= 0 and $Dm >= 0
!ll&&!rl&&r
211019
$Dy <= 0 and $Dm <= 0 and $Dd <= 0
!ll&&!rl&&r
23107
$Dy <= 0 and $Dm <= 0
!ll&&!rl&&r
16717
MC/DC100%6/6
$Dy >= 0 and $Dm >= 0 and $Dd >= 0 or $Dy <= 0 and $Dm <= 0 and $Dd <= 0
$Dy >= 0 $Dm >= 0 $Dd >= 0 $Dy <= 0 $Dm <= 0 $Dd <= 0
Truth table53%7/13
A and B and C or D and E and F
A= $Dy >= 0B= $Dm >= 0C= $Dd >= 0D= $Dy <= 0E= $Dm <= 0F= $Dd <= 0
ABCDEFresult
111XXX1
0XX1111
10X1111
1101111
0XX0XX0
0XX10X0
0XX1100
10X0XX0
10X10X0
10X1100
1100XX0
11010X0
1101100
1744 (($Dy <= 0) and ($Dm <= 0) and ($Dd <= 0)))
1745 {
1746 33 ▶ if (($Dy < 0) and ($Dm > 0)) { $Dy++; $Dm -= 12; }
Branch: 2 branches
BranchTrueFalseTotal
if ($Dy < 0 and $Dm > 0) { } 7 26 33
elsif ($Dy > 0 and $Dm < 0) { } 7 29 36
Condition100%3/3
$Dy < 0 and $Dm > 0
!ll&&!rl&&r
16107
MC/DC100%2/2
$Dy < 0 and $Dm > 0
$Dy < 0 $Dm > 0
Truth table100%3/3
A and B
A= $Dy < 0B= $Dm > 0
ABresult
0X0
100
111
1747 7 ▶ elsif (($Dy > 0) and ($Dm < 0)) { $Dy--; $Dm += 12; }
Condition100%3/3
$Dy > 0 and $Dm < 0
!ll&&!rl&&r
1097
MC/DC100%2/2
$Dy > 0 and $Dm < 0
$Dy > 0 $Dm < 0
Truth table100%3/3
A and B
A= $Dy > 0B= $Dm < 0
ABresult
0X0
100
111
1748 33 ▶ if (($Dm < 0) and ($Dd > 0)) { $Dm++; $ty=$$_year1; $tm=$$_month1; $td=$$_day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 3 branches
BranchTrueFalseTotal
if ($Dm < 0 and $Dd > 0) { } 4 29 33
elsif ($Dm > 0 and $Dd < 0) { } 5 43 48
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 4 4
Condition100%3/3
$Dm < 0 and $Dd > 0
!ll&&!rl&&r
2454
MC/DC100%2/2
$Dm < 0 and $Dd > 0
$Dm < 0 $Dd > 0
Truth table100%3/3
A and B
A= $Dm < 0B= $Dd > 0
ABresult
0X0
100
111
1749 5 ▶ elsif (($Dm > 0) and ($Dd < 0)) { $Dm--; $ty=$$_year1; $tm=$$_month1; $td=$$_day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 5 5
Condition100%3/3
$Dm > 0 and $Dd < 0
!ll&&!rl&&r
1955
MC/DC100%2/2
$Dm > 0 and $Dd < 0
$Dm > 0 $Dd < 0
Truth table100%3/3
A and B
A= $Dm > 0B= $Dd < 0
ABresult
0X0
100
111
1750 33 ▶ if (($Dy < 0) and ($Dd > 0)) { $Dy++; $Dm -= 12; }
Branch: 2 branches
BranchTrueFalseTotal
if ($Dy < 0 and $Dd > 0) { } 8 25 33
elsif ($Dy > 0 and $Dd < 0) { } 6 33 39
Condition100%3/3
$Dy < 0 and $Dd > 0
!ll&&!rl&&r
2148
MC/DC100%2/2
$Dy < 0 and $Dd > 0
$Dy < 0 $Dd > 0
Truth table100%3/3
A and B
A= $Dy < 0B= $Dd > 0
ABresult
0X0
100
111
1751 6 ▶ elsif (($Dy > 0) and ($Dd < 0)) { $Dy--; $Dm += 12; }
Condition100%3/3
$Dy > 0 and $Dd < 0
!ll&&!rl&&r
1456
MC/DC100%2/2
$Dy > 0 and $Dd < 0
$Dy > 0 $Dd < 0
Truth table100%3/3
A and B
A= $Dy > 0B= $Dd < 0
ABresult
0X0
100
111
1752 33 ▶ if (($Dm < 0) and ($Dd > 0)) { $Dm++; $ty=$$_year1; $tm=$$_month1; $td=$$_day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 3 branches
BranchTrueFalseTotal
if ($Dm < 0 and $Dd > 0) { } 8 25 33
elsif ($Dm > 0 and $Dd < 0) { } 6 31 37
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 8 8
Condition100%3/3
$Dm < 0 and $Dd > 0
!ll&&!rl&&r
1878
MC/DC100%2/2
$Dm < 0 and $Dd > 0
$Dm < 0 $Dd > 0
Truth table100%3/3
A and B
A= $Dm < 0B= $Dd > 0
ABresult
0X0
100
111
1753 6 ▶ elsif (($Dm > 0) and ($Dd < 0)) { $Dm--; $ty=$$_year1; $tm=$$_month1; $td=$$_day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 6 6
Condition100%3/3
$Dm > 0 and $Dd < 0
!ll&&!rl&&r
1276
MC/DC100%2/2
$Dm > 0 and $Dd < 0
$Dm > 0 $Dd < 0
Truth table100%3/3
A and B
A= $Dm > 0B= $Dd < 0
ABresult
0X0
100
111
1754 }
1755 }
1756 74 $$_year1 = $Dy;
1757 74 $$_month1 = $Dm;
1758 74 $$_day1 = $Dd;
1759 74 return 1;
1760 }
1761 8 return 0;
1762 }
1763  
1764 sub DateCalc_norm_delta_ymdhms
1765 80 ▶{
Subroutine DateCalc_norm_delta_ymdhms: called CC=64 SCAR=42.4
Pod undocumented
1766 80 my($_D_y,$_D_m,$_D_d,$_Dhh,$_Dmm,$_Dss,$year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2) = @_;
1767 80 my($Dy) = 0;
1768 80 my($Dm) = 0;
1769 80 my($Dd) = 0;
1770 80 my($d2,$ty,$tm,$td,$hh,$mm,$ss);
1771 80 ▶ if (DateCalc_check_date($year1,$month1,$day1) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_date($year2, $month2, $day2) and DateCalc_check_time($hour1, $min2, $sec2)) 80 0 80
Condition33%3/9
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_date($year2, $month2, $day2) and DateCalc_check_time($hour1, $min2, $sec2)
!ll&&!rl&&r
0080
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_date($year2, $month2, $day2)
!ll&&!rl&&r
0080
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_time($hour1, $min1, $sec1)
!ll&&!rl&&r
0080
MC/DC0%0/4
DateCalc_check_date($year1, $month1, $day1) and DateCalc_check_time($hour1, $min1, $sec1) and DateCalc_check_date($year2, $month2, $day2) and DateCalc_check_time($hour1, $min2, $sec2)
DateCalc_check_date($year1, $month1, $day1) DateCalc_check_time($hour1, $min1, $sec1) DateCalc_check_date($year2, $month2, $day2) DateCalc_check_time($hour1, $min2, $sec2)
Truth table20%1/5
A and B and C and D
A= DateCalc_check_date($year1, $month1, $day1)B= DateCalc_check_time($hour1, $min1, $sec1)C= DateCalc_check_date($year2, $month2, $day2)D= DateCalc_check_time($hour1, $min2, $sec2)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1772 DateCalc_check_time($hour1,$min1, $sec1) and
1773 DateCalc_check_date($year2,$month2,$day2) and
1774 DateCalc_check_time($hour1,$min2, $sec2))
1775 {
1776 80 $ss = ( ($hour2-$hour1) * 60 + ($min2-$min1) ) * 60 + ($sec2-$sec1);
1777 80 $d2 = DateCalc_Date_to_Days($year2,$month2,$day2);
1778 80 $Dd = $d2-DateCalc_Date_to_Days($year1,$month1,$day1);
1779 80 ▶ if (($Dd < -30) or ($Dd > 30))
Branch: 1 branch
BranchTrueFalseTotal
if ($Dd < -30 or $Dd > 30) { } 52 28 80
Condition100%3/3
$Dd < -30 or $Dd > 30
l!l&&r!l&&!r
262628
MC/DC100%2/2
$Dd < -30 or $Dd > 30
$Dd < -30 $Dd > 30
Truth table100%3/3
A or B
A= $Dd < -30B= $Dd > 30
ABresult
1X1
011
000
1780 {
1781 52 $Dy = $year2 - $year1;
1782 52 $Dm = $month2 - $month1;
1783 52 ▶ $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td);
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 52 52
1784 52 ▶ unless ((($Dy >= 0) and ($Dm >= 0) and ($Dd >= 0) and ($ss >= 0)) or
Branch: 1 branch
BranchTrueFalseTotal
unless ($Dy >= 0 and $Dm >= 0 and $Dd >= 0 and $ss >= 0 or $Dy <= 0 and $Dm <= 0 and $Dd <= 0 and $ss <= 0) 46 6 52
Condition100%21/21
$Dy >= 0 and $Dm >= 0 and $Dd >= 0 and $ss >= 0 or $Dy <= 0 and $Dm <= 0 and $Dd <= 0 and $ss <= 0
l!l&&r!l&&!r
4246
$Dy >= 0 and $Dm >= 0 and $Dd >= 0 and $ss >= 0
!ll&&!rl&&r
4084
$Dy >= 0 and $Dm >= 0 and $Dd >= 0
!ll&&!rl&&r
32812
$Dy >= 0 and $Dm >= 0
!ll&&!rl&&r
221020
$Dy <= 0 and $Dm <= 0 and $Dd <= 0 and $ss <= 0
!ll&&!rl&&r
4062
$Dy <= 0 and $Dm <= 0 and $Dd <= 0
!ll&&!rl&&r
28128
$Dy <= 0 and $Dm <= 0
!ll&&!rl&&r
181020
MC/DC87%7/8
$Dy >= 0 and $Dm >= 0 and $Dd >= 0 and $ss >= 0 or $Dy <= 0 and $Dm <= 0 and $Dd <= 0 and $ss <= 0
$Dy >= 0 $Dm >= 0 $Dd >= 0 $ss >= 0 $Dy <= 0 $Dm <= 0 $Dd <= 0 $ss <= 0
Truth table47%10/21
A and B and C and D or E and F and G and H
A= $Dy >= 0B= $Dm >= 0C= $Dd >= 0D= $ss >= 0E= $Dy <= 0F= $Dm <= 0G= $Dd <= 0H= $ss <= 0
ABCDEFGHresult
1111XXXX1
0XXX11111
10XX11111
110X11111
111011111
0XXX0XXX0
0XXX10XX0
0XXX110X0
0XXX11100
10XX0XXX0
10XX10XX0
10XX110X0
10XX11100
110X0XXX0
110X10XX0
110X110X0
110X11100
11100XXX0
111010XX0
1110110X0
111011100
1785 (($Dy <= 0) and ($Dm <= 0) and ($Dd <= 0) and ($ss <= 0)))
1786 {
1787 46 ▶ if (($Dy < 0) and ($Dm > 0)) { $Dy++; $Dm -= 12; }
Branch: 2 branches
BranchTrueFalseTotal
if ($Dy < 0 and $Dm > 0) { } 6 40 46
elsif ($Dy > 0 and $Dm < 0) { } 6 56 62
Condition100%3/3
$Dy < 0 and $Dm > 0
!ll&&!rl&&r
26146
MC/DC100%2/2
$Dy < 0 and $Dm > 0
$Dy < 0 $Dm > 0
Truth table100%3/3
A and B
A= $Dy < 0B= $Dm > 0
ABresult
0X0
100
111
1788 6 ▶ elsif (($Dy > 0) and ($Dm < 0)) { $Dy--; $Dm += 12; }
Condition100%3/3
$Dy > 0 and $Dm < 0
!ll&&!rl&&r
22126
MC/DC100%2/2
$Dy > 0 and $Dm < 0
$Dy > 0 $Dm < 0
Truth table100%3/3
A and B
A= $Dy > 0B= $Dm < 0
ABresult
0X0
100
111
1789 46 ▶ if (($Dm < 0) and ($Dd > 0)) { $Dm++; $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 3 branches
BranchTrueFalseTotal
if ($Dm < 0 and $Dd > 0) { } 4 42 46
elsif ($Dm > 0 and $Dd < 0) { } 4 66 70
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 4 4
Condition100%3/3
$Dm < 0 and $Dd > 0
!ll&&!rl&&r
32104
MC/DC100%2/2
$Dm < 0 and $Dd > 0
$Dm < 0 $Dd > 0
Truth table100%3/3
A and B
A= $Dm < 0B= $Dd > 0
ABresult
0X0
100
111
1790 4 ▶ elsif (($Dm > 0) and ($Dd < 0)) { $Dm--; $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 4 4
Condition100%3/3
$Dm > 0 and $Dd < 0
!ll&&!rl&&r
28104
MC/DC100%2/2
$Dm > 0 and $Dd < 0
$Dm > 0 $Dd < 0
Truth table100%3/3
A and B
A= $Dm > 0B= $Dd < 0
ABresult
0X0
100
111
1791 46 ▶ if (($Dy < 0) and ($Dd > 0)) { $Dy++; $Dm -= 12; }
Branch: 2 branches
BranchTrueFalseTotal
if ($Dy < 0 and $Dd > 0) { } 10 36 46
elsif ($Dy > 0 and $Dd < 0) { } 6 52 58
Condition100%3/3
$Dy < 0 and $Dd > 0
!ll&&!rl&&r
30610
MC/DC100%2/2
$Dy < 0 and $Dd > 0
$Dy < 0 $Dd > 0
Truth table100%3/3
A and B
A= $Dy < 0B= $Dd > 0
ABresult
0X0
100
111
1792 6 ▶ elsif (($Dy > 0) and ($Dd < 0)) { $Dy--; $Dm += 12; }
Condition100%3/3
$Dy > 0 and $Dd < 0
!ll&&!rl&&r
2286
MC/DC100%2/2
$Dy > 0 and $Dd < 0
$Dy > 0 $Dd < 0
Truth table100%3/3
A and B
A= $Dy > 0B= $Dd < 0
ABresult
0X0
100
111
1793 46 ▶ if (($Dm < 0) and ($Dd > 0)) { $Dm++; $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 3 branches
BranchTrueFalseTotal
if ($Dm < 0 and $Dd > 0) { } 10 36 46
elsif ($Dm > 0 and $Dd < 0) { } 6 48 54
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 10 10
Condition100%3/3
$Dm < 0 and $Dd > 0
!ll&&!rl&&r
241210
MC/DC100%2/2
$Dm < 0 and $Dd > 0
$Dm < 0 $Dd > 0
Truth table100%3/3
A and B
A= $Dm < 0B= $Dd > 0
ABresult
0X0
100
111
1794 6 ▶ elsif (($Dm > 0) and ($Dd < 0)) { $Dm--; $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 6 6
Condition100%3/3
$Dm > 0 and $Dd < 0
!ll&&!rl&&r
18126
MC/DC100%2/2
$Dm > 0 and $Dd < 0
$Dm > 0 $Dd < 0
Truth table100%3/3
A and B
A= $Dm > 0B= $Dd < 0
ABresult
0X0
100
111
1795 46 ▶ if (($Dd < 0) and ($ss > 0)) { $Dd++; $ss -= 86400; }
Branch: 2 branches
BranchTrueFalseTotal
if ($Dd < 0 and $ss > 0) { } 14 32 46
elsif ($Dd > 0 and $ss < 0) { } 14 32 46
Condition100%3/3
$Dd < 0 and $ss > 0
!ll&&!rl&&r
26614
MC/DC100%2/2
$Dd < 0 and $ss > 0
$Dd < 0 $ss > 0
Truth table100%3/3
A and B
A= $Dd < 0B= $ss > 0
ABresult
0X0
100
111
1796 14 ▶ elsif (($Dd > 0) and ($ss < 0)) { $Dd--; $ss += 86400; }
Condition100%3/3
$Dd > 0 and $ss < 0
!ll&&!rl&&r
14414
MC/DC100%2/2
$Dd > 0 and $ss < 0
$Dd > 0 $ss < 0
Truth table100%3/3
A and B
A= $Dd > 0B= $ss < 0
ABresult
0X0
100
111
1797 46 ▶ if (($Dm < 0) and ($ss > 0)) { $Dm++; $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 3 branches
BranchTrueFalseTotal
if ($Dm < 0 and $ss > 0) { } 4 42 46
elsif ($Dm > 0 and $ss < 0) { } 2 64 66
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 4 4
Condition100%3/3
$Dm < 0 and $ss > 0
!ll&&!rl&&r
24184
MC/DC100%2/2
$Dm < 0 and $ss > 0
$Dm < 0 $ss > 0
Truth table100%3/3
A and B
A= $Dm < 0B= $ss > 0
ABresult
0X0
100
111
1798 2 ▶ elsif (($Dm > 0) and ($ss < 0)) { $Dm--; $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 2 2
Condition100%3/3
$Dm > 0 and $ss < 0
!ll&&!rl&&r
24162
MC/DC100%2/2
$Dm > 0 and $ss < 0
$Dm > 0 $ss < 0
Truth table100%3/3
A and B
A= $Dm > 0B= $ss < 0
ABresult
0X0
100
111
1799 0 ▶ if (($Dy < 0) and ($ss > 0)) { $Dy++; $Dm -= 12; }
Branch: 2 branches
BranchTrueFalseTotal
if ($Dy < 0 and $ss > 0) { } 0 46 46
elsif ($Dy > 0 and $ss < 0) { } 2 82 84
Condition66%2/3
$Dy < 0 and $ss > 0
!ll&&!rl&&r
4060
MC/DC0%0/2
$Dy < 0 and $ss > 0
$Dy < 0 $ss > 0
Truth table66%2/3
A and B
A= $Dy < 0B= $ss > 0
ABresult
0X0
100
111
1800 2 ▶ elsif (($Dy > 0) and ($ss < 0)) { $Dy--; $Dm += 12; }
Condition100%3/3
$Dy > 0 and $ss < 0
!ll&&!rl&&r
3862
MC/DC100%2/2
$Dy > 0 and $ss < 0
$Dy > 0 $ss < 0
Truth table100%3/3
A and B
A= $Dy > 0B= $ss < 0
ABresult
0X0
100
111
1801 0 ▶ if (($Dm < 0) and ($ss > 0)) { $Dm++; $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 3 branches
BranchTrueFalseTotal
if ($Dm < 0 and $ss > 0) { } 0 46 46
elsif ($Dm > 0 and $ss < 0) { } 2 72 74
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 0 0
Condition66%2/3
$Dm < 0 and $ss > 0
!ll&&!rl&&r
28180
MC/DC0%0/2
$Dm < 0 and $ss > 0
$Dm < 0 $ss > 0
Truth table66%2/3
A and B
A= $Dm < 0B= $ss > 0
ABresult
0X0
100
111
1802 2 ▶ elsif (($Dm > 0) and ($ss < 0)) { $Dm--; $ty=$year1; $tm=$month1; $td=$day1; return 0 unless (DateCalc_add_delta_ym(\$ty,\$tm,\$td,$Dy,$Dm)); $Dd=$d2-DateCalc_Date_to_Days($ty,$tm,$td); }
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym(\$ty, \$tm, \$td, $Dy, $Dm) 0 2 2
Condition100%3/3
$Dm > 0 and $ss < 0
!ll&&!rl&&r
28162
MC/DC100%2/2
$Dm > 0 and $ss < 0
$Dm > 0 $ss < 0
Truth table100%3/3
A and B
A= $Dm > 0B= $ss < 0
ABresult
0X0
100
111
1803 46 ▶ if (($Dd < 0) and ($ss > 0)) { $Dd++; $ss -= 86400; }
Branch: 2 branches
BranchTrueFalseTotal
if ($Dd < 0 and $ss > 0) { } 4 42 46
elsif ($Dd > 0 and $ss < 0) { } 4 62 66
Condition100%3/3
$Dd < 0 and $ss > 0
!ll&&!rl&&r
30124
MC/DC100%2/2
$Dd < 0 and $ss > 0
$Dd < 0 $ss > 0
Truth table100%3/3
A and B
A= $Dd < 0B= $ss > 0
ABresult
0X0
100
111
1804 4 ▶ elsif (($Dd > 0) and ($ss < 0)) { $Dd--; $ss += 86400; }
Condition100%3/3
$Dd > 0 and $ss < 0
!ll&&!rl&&r
24144
MC/DC100%2/2
$Dd > 0 and $ss < 0
$Dd > 0 $ss < 0
Truth table100%3/3
A and B
A= $Dd > 0B= $ss < 0
ABresult
0X0
100
111
1805 }
1806 }
1807 else
1808 {
1809 28 ▶ if (($Dd < 0) and ($ss > 0)) { $Dd++; $ss -= 86400; }
Branch: 2 branches
BranchTrueFalseTotal
if ($Dd < 0 and $ss > 0) { } 12 16 28
elsif ($Dd > 0 and $ss < 0) { } 12 6 18
Condition100%3/3
$Dd < 0 and $ss > 0
!ll&&!rl&&r
14212
MC/DC100%2/2
$Dd < 0 and $ss > 0
$Dd < 0 $ss > 0
Truth table100%3/3
A and B
A= $Dd < 0B= $ss > 0
ABresult
0X0
100
111
1810 12 ▶ elsif (($Dd > 0) and ($ss < 0)) { $Dd--; $ss += 86400; }
Condition100%3/3
$Dd > 0 and $ss < 0
!ll&&!rl&&r
2212
MC/DC100%2/2
$Dd > 0 and $ss < 0
$Dd > 0 $ss < 0
Truth table100%3/3
A and B
A= $Dd > 0B= $ss < 0
ABresult
0X0
100
111
1811 }
1812 80 $mm = int( $ss / 60 );
1813 80 $ss -= $mm * 60;
1814 80 $hh = int( $mm / 60 );
1815 80 $mm -= $hh * 60;
1816 80 $$_D_y = $Dy;
1817 80 $$_D_m = $Dm;
1818 80 $$_D_d = $Dd;
1819 80 $$_Dhh = $hh;
1820 80 $$_Dmm = $mm;
1821 80 $$_Dss = $ss;
1822 80 return 1;
1823 }
1824 0 return 0;
1825 }
1826  
1827 sub DateCalc_add_delta_days
1828 4464 ▶{
Subroutine DateCalc_add_delta_days: called CC=8 SCAR=21.0
Pod undocumented
1829 4464 my($_year,$_month,$_day,$Dd) = @_;
1830 4464 my($days,$leap);
1831 4464 ▶ if ((($days = DateCalc_Date_to_Days($$_year,$$_month,$$_day)) > 0) and
Branch: 1 branch
BranchTrueFalseTotal
if (($days = DateCalc_Date_to_Days($$_year, $$_month, $$_day)) > 0 and ($days += $Dd) > 0) 4459 5 4464
Condition100%3/3
($days = DateCalc_Date_to_Days($$_year, $$_month, $$_day)) > 0 and ($days += $Dd) > 0
!ll&&!rl&&r
234459
MC/DC100%2/2
($days = DateCalc_Date_to_Days($$_year, $$_month, $$_day)) > 0 and ($days += $Dd) > 0
($days = DateCalc_Date_to_Days($$_year, $$_month, $$_day)) > 0 ($days += $Dd) > 0
Truth table100%3/3
A and B
A= ($days = DateCalc_Date_to_Days($$_year, $$_month, $$_day)) > 0B= ($days += $Dd) > 0
ABresult
0X0
100
111
1832 (($days += $Dd) > 0))
1833 {
1834 4459 ▶ if ($Dd != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Dd != 0) 4350 109 4459
1835 {
1836 4350 $$_year = int( $days / 365.2425 );
1837 4350 $$_day = $days - DateCalc_Year_to_Days($$_year);
1838 4350 ▶ if ($$_day < 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_day < 1) { } 4 4346 4350
1839 {
1840 4 $$_day = $days - DateCalc_Year_to_Days($$_year-1);
1841 }
1842 4346 else { ${$_year}++; }
1843 4350 $leap = DateCalc_leap_year($$_year);
1844 4350 ▶ if ($$_day > $DateCalc_Days_in_Year_[$leap][13])
Branch: 1 branch
BranchTrueFalseTotal
if ($$_day > $DateCalc_Days_in_Year_[$leap][13]) 0 4350 4350
1845 {
1846 0 $$_day -= $DateCalc_Days_in_Year_[$leap][13];
1847 0 $leap = DateCalc_leap_year(++${$_year});
1848 }
1849 4350 ▶ for ( $$_month = 12; $$_month >= 1; ${$_month}-- )
Branch: 1 branch
BranchTrueFalseTotal
if ($$_month >= 1) 31246 0 31246
1850 {
1851 31246 ▶ if ($$_day > $DateCalc_Days_in_Year_[$leap][$$_month])
Branch: 1 branch
BranchTrueFalseTotal
if ($$_day > $DateCalc_Days_in_Year_[$leap][$$_month]) 4350 26896 31246
1852 {
1853 4350 $$_day -= $DateCalc_Days_in_Year_[$leap][$$_month];
1854 4350 last;
1855 }
1856 }
1857 }
1858 4459 return 1;
1859 }
1860 5 return 0;
1861 }
1862  
1863 sub DateCalc_add_delta_dhms
1864 138 ▶{
Subroutine DateCalc_add_delta_dhms: called CC=5 SCAR=16.3
Pod undocumented
1865 138 my($_year,$_month,$_day,$_hour,$_min,$_sec,$Dd,$Dh,$Dm,$Ds) = @_;
1866 138 ▶ if (DateCalc_check_date($$_year,$$_month,$$_day) and
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($$_year, $$_month, $$_day) and DateCalc_check_time($$_hour, $$_min, $$_sec)) 138 0 138
Condition33%1/3
DateCalc_check_date($$_year, $$_month, $$_day) and DateCalc_check_time($$_hour, $$_min, $$_sec)
!ll&&!rl&&r
00138
MC/DC0%0/2
DateCalc_check_date($$_year, $$_month, $$_day) and DateCalc_check_time($$_hour, $$_min, $$_sec)
DateCalc_check_date($$_year, $$_month, $$_day) DateCalc_check_time($$_hour, $$_min, $$_sec)
Truth table33%1/3
A and B
A= DateCalc_check_date($$_year, $$_month, $$_day)B= DateCalc_check_time($$_hour, $$_min, $$_sec)
ABresult
0X0
100
111
1867 DateCalc_check_time($$_hour,$$_min, $$_sec))
1868 {
1869 138 DateCalc_Normalize_Ranges(\$Dd,\$Dh,\$Dm,\$Ds);
1870 138 $Ds += (((($$_hour * 60) + $$_min) * 60) + $$_sec) +
1871 ((( $Dh * 60) + $Dm) * 60);
1872 138 ▶ while ($Ds < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Ds < 0) 51 138 189
1873 {
1874 51 $Ds += 86400;
1875 51 $Dd--;
1876 }
1877 138 ▶ if ($Ds > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Ds > 0) { } 119 19 138
1878 {
1879 119 $Dh = 0;
1880 119 $Dm = 0;
1881 119 DateCalc_Normalize_Time(\$Dd,\$Dh,\$Dm,\$Ds);
1882 119 $$_hour = $Dh;
1883 119 $$_min = $Dm;
1884 119 $$_sec = $Ds;
1885 }
1886 19 else { $$_hour = $$_min = $$_sec = 0; }
1887 138 return DateCalc_add_delta_days($_year,$_month,$_day,$Dd);
1888 }
1889 0 return 0;
1890 }
1891  
1892 sub DateCalc_add_year_month
1893 461 ▶{
Subroutine DateCalc_add_year_month: called CC=8 SCAR=21.1
Pod undocumented
1894 461 my($_year,$_month,$Dy,$Dm) = @_;
1895 461 my($quot);
1896 461 ▶ return 0 if (($$_year < 1) or ($$_month < 1) or ($$_month > 12));
Branch: 1 branch
BranchTrueFalseTotal
if $$_year < 1 or $$_month < 1 or $$_month > 12 0 461 461
Condition33%2/6
$$_year < 1 or $$_month < 1 or $$_month > 12
l!l&&r!l&&!r
00461
$$_year < 1 or $$_month < 1
l!l&&r!l&&!r
00461
MC/DC0%0/3
$$_year < 1 or $$_month < 1 or $$_month > 12
$$_year < 1 $$_month < 1 $$_month > 12
Truth table25%1/4
A or B or C
A= $$_year < 1B= $$_month < 1C= $$_month > 12
ABCresult
1XX1
01X1
0011
0000
1897 461 ▶ if ($Dm != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Dm != 0) 245 216 461
1898 {
1899 245 $Dm += $$_month - 1;
1900 245 $quot = int($Dm / 12);
1901 245 $Dm -= $quot * 12;
1902 245 ▶ if ($Dm < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Dm < 0) 69 176 245
1903 {
1904 69 $Dm += 12;
1905 69 $quot--;
1906 }
1907 245 $$_month = $Dm + 1;
1908 245 $Dy += $quot;
1909 }
1910 461 ▶ if ($Dy != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($Dy != 0) 271 190 461
1911 {
1912 271 $$_year += $Dy;
1913 }
1914 461 ▶ return 0 if ($$_year < 1);
Branch: 1 branch
BranchTrueFalseTotal
if $$_year < 1 2 459 461
1915 459 return 1;
1916 }
1917  
1918 sub DateCalc_add_delta_ym
1919 407 ▶{
Subroutine DateCalc_add_delta_ym: called CC=4 SCAR=14.0
Pod undocumented
1920 407 my($_year,$_month,$_day,$Dy,$Dm) = @_;
1921 407 my($Dd);
1922 407 ▶ return 0 unless (DateCalc_check_date($$_year,$$_month,$$_day));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_check_date($$_year, $$_month, $$_day) 0 407 407
1923 407 ▶ return 0 unless (DateCalc_add_year_month($_year,$_month,$Dy,$Dm));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_year_month($_year, $_month, $Dy, $Dm) 0 407 407
1924 407 ▶ if ($$_day > ($Dd = $DateCalc_Days_in_Month_[DateCalc_leap_year($$_year)][$$_month]))
Branch: 1 branch
BranchTrueFalseTotal
if ($$_day > ($Dd = $DateCalc_Days_in_Month_[DateCalc_leap_year($$_year)][$$_month])) 50 357 407
1925 {
1926 50 $$_day = $Dd;
1927 }
1928 407 return 1;
1929 }
1930  
1931 sub DateCalc_add_delta_ymd
1932 53 ▶{
Subroutine DateCalc_add_delta_ymd: called CC=3 SCAR=11.0
Pod undocumented
1933 53 my($_year,$_month,$_day,$Dy,$Dm,$Dd) = @_;
1934 53 ▶ return 0 unless (DateCalc_check_date($$_year,$$_month,$$_day));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_check_date($$_year, $$_month, $$_day) 5 48 53
1935 48 ▶ return 0 unless (DateCalc_add_year_month($_year,$_month,$Dy,$Dm));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_year_month($_year, $_month, $Dy, $Dm) 2 46 48
1936 46 $Dd += $$_day - 1;
1937 46 $$_day = 1;
1938 46 return DateCalc_add_delta_days($_year,$_month,$_day,$Dd);
1939 }
1940  
1941 sub DateCalc_add_delta_ymdhms
1942 6 ▶{
Subroutine DateCalc_add_delta_ymdhms: called CC=4 SCAR=15.0
Pod undocumented
1943 6 my($_year,$_month,$_day,$_hour,$_min,$_sec,$D_y,$D_m,$D_d,$Dh,$Dm,$Ds) = @_;
1944 6 ▶ return 0 unless (DateCalc_check_date($$_year,$$_month,$$_day) and DateCalc_check_time($$_hour,$$_min,$$_sec));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_check_date($$_year, $$_month, $$_day) and DateCalc_check_time($$_hour, $$_min, $$_sec) 0 6 6
Condition33%1/3
DateCalc_check_date($$_year, $$_month, $$_day) and DateCalc_check_time($$_hour, $$_min, $$_sec)
!ll&&!rl&&r
006
MC/DC0%0/2
DateCalc_check_date($$_year, $$_month, $$_day) and DateCalc_check_time($$_hour, $$_min, $$_sec)
DateCalc_check_date($$_year, $$_month, $$_day) DateCalc_check_time($$_hour, $$_min, $$_sec)
Truth table33%1/3
A and B
A= DateCalc_check_date($$_year, $$_month, $$_day)B= DateCalc_check_time($$_hour, $$_min, $$_sec)
ABresult
0X0
100
111
1945 6 ▶ return 0 unless (DateCalc_add_year_month($_year,$_month,$D_y,$D_m));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_year_month($_year, $_month, $D_y, $D_m) 0 6 6
1946 6 $D_d += $$_day - 1;
1947 6 $$_day = 1;
1948 6 return DateCalc_add_delta_dhms($_year,$_month,$_day,$_hour,$_min,$_sec,$D_d,$Dh,$Dm,$Ds);
1949 }
1950  
1951 sub DateCalc_add_norm_delta_ymd
1952 96 ▶{
Subroutine DateCalc_add_norm_delta_ymd: called CC=2 SCAR=7.1
Pod undocumented
1953 96 my($_year,$_month,$_day,$Dy,$Dm,$Dd) = @_;
1954 96 ▶ return 0 unless (DateCalc_add_delta_ym($_year,$_month,$_day,$Dy,$Dm));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym($_year, $_month, $_day, $Dy, $Dm) 0 96 96
1955 96 return DateCalc_add_delta_days($_year,$_month,$_day,$Dd);
1956 }
1957  
1958 sub DateCalc_add_norm_delta_ymdhms
1959 80 ▶{
Subroutine DateCalc_add_norm_delta_ymdhms: called CC=2 SCAR=7.1
Pod undocumented
1960 80 my($_year,$_month,$_day,$_hour,$_min,$_sec,$D_y,$D_m,$D_d,$Dh,$Dm,$Ds) = @_;
1961 80 ▶ return 0 unless (DateCalc_add_delta_ym($_year,$_month,$_day,$D_y,$D_m));
Branch: 1 branch
BranchTrueFalseTotal
unless DateCalc_add_delta_ym($_year, $_month, $_day, $D_y, $D_m) 0 80 80
1962 80 return DateCalc_add_delta_dhms($_year,$_month,$_day,$_hour,$_min,$_sec,$D_d,$Dh,$Dm,$Ds);
1963 }
1964  
1965 sub DateCalc_system_clock
1966 1 ▶{
Subroutine DateCalc_system_clock: called CC=6 SCAR=20.7
Pod undocumented
1967 1 my($_year,$_month,$_day,$_hour,$_min,$_sec,$_doy,$_dow,$_dst,$gmt) = @_;
1968 1 my($seconds) = time();
1969 1 ▶ if ($seconds >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds >= 0) 1 0 1
1970 {
1971 1 $$_dst = 0;
1972 0 ▶ if ($gmt) { ($$_sec,$$_min,$$_hour,$$_day,$$_month,$$_year,$$_dow,$$_doy) = gmtime($seconds); }
Branch: 1 branch
BranchTrueFalseTotal
if ($gmt) { } 0 1 1
1973 1 else { ($$_sec,$$_min,$$_hour,$$_day,$$_month,$$_year,$$_dow,$$_doy,$$_dst) = localtime($seconds); }
1974 1 ${$_year} += 1900;
1975 1 ${$_month}++;
1976 0 ▶ ${$_dow} = 7 if (${$_dow} == 0);
Branch: 1 branch
BranchTrueFalseTotal
if ${$_dow;} == 0 0 1 1
1977 1 ${$_doy}++;
1978 1 ▶ if ($$_dst != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_dst != 0) 0 1 1
1979 {
1980 0 ▶ if ($$_dst < 0) { $$_dst = -1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($$_dst < 0) { } 0 0 0
1981 0 else { $$_dst = 1; }
1982 }
1983 1 return 1;
1984 }
1985 0 return 0;
1986 }
1987  
1988 sub DateCalc_gmtime
1989 2 ▶{
Subroutine DateCalc_gmtime: called CC=3 SCAR=11.3
Pod undocumented
1990 2 my($_year,$_month,$_day,$_hour,$_min,$_sec,$_doy,$_dow,$_dst,$seconds) = @_;
1991 2 ▶ if ($seconds >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds >= 0) 2 0 2
1992 {
1993 2 $$_dst = 0;
1994 2 ($$_sec,$$_min,$$_hour,$$_day,$$_month,$$_year,$$_dow,$$_doy) = gmtime($seconds);
1995 2 ${$_year} += 1900;
1996 2 ${$_month}++;
1997 0 ▶ ${$_dow} = 7 if (${$_dow} == 0);
Branch: 1 branch
BranchTrueFalseTotal
if ${$_dow;} == 0 0 2 2
1998 2 ${$_doy}++;
1999 2 return 1;
2000 }
2001 0 return 0;
2002 }
2003  
2004 sub DateCalc_localtime
2005 2 ▶{
Subroutine DateCalc_localtime: called CC=5 SCAR=18.6
Pod undocumented
2006 2 my($_year,$_month,$_day,$_hour,$_min,$_sec,$_doy,$_dow,$_dst,$seconds) = @_;
2007 2 ▶ if ($seconds >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($seconds >= 0) 2 0 2
2008 {
2009 2 ($$_sec,$$_min,$$_hour,$$_day,$$_month,$$_year,$$_dow,$$_doy,$$_dst) = localtime($seconds);
2010 2 ${$_year} += 1900;
2011 2 ${$_month}++;
2012 0 ▶ ${$_dow} = 7 if (${$_dow} == 0);
Branch: 1 branch
BranchTrueFalseTotal
if ${$_dow;} == 0 0 2 2
2013 2 ${$_doy}++;
2014 2 ▶ if ($$_dst != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_dst != 0) 0 2 2
2015 {
2016 0 ▶ if ($$_dst < 0) { $$_dst = -1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($$_dst < 0) { } 0 0 0
2017 0 else { $$_dst = 1; }
2018 }
2019 2 return 1;
2020 }
2021 0 return 0;
2022 }
2023  
2024 ## MacOS (Classic): ##
2025 ## <695056.0> = Fri 1-Jan-1904 00:00:00 (time=0x00000000) ##
2026 ## <744766.23295> = Mon 6-Feb-2040 06:28:15 (time=0xFFFFFFFF) ##
2027  
2028 ## Unix: ##
2029 ## <719163.0> = Thu 1-Jan-1970 00:00:00 (time=0x00000000) ##
2030 ## <744018.11647> = Tue 19-Jan-2038 03:14:07 (time=0x7FFFFFFF) ##
2031  
2032 sub DateCalc_mktime
2033 2 ▶{
Subroutine DateCalc_mktime: called CC=53 SCAR=72.2
Pod undocumented
2034 2 my($_seconds,$year,$month,$day,$hour,$min,$sec,$doy,$dow,$dst) = @_;
2035 2 $$_seconds = 0;
2036 2 ▶ if ($^O eq 'MacOS')
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'MacOS') { } 0 2 2
2037 {
2038 0 ▶ return 0 if
Branch: 1 branch
BranchTrueFalseTotal
if $year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59 or $sec < 0 or $sec > 59 0 0 0
Condition0%0/33
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59 or $sec < 0 or $sec > 59
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59 or $sec < 0
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1 or $month > 12
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040 or $month < 1
l!l&&r!l&&!r
000
$year < 1904 or $year > 2040
l!l&&r!l&&!r
000
MC/DC0%0/12
$year < 1904 or $year > 2040 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59 or $sec < 0 or $sec > 59
$year < 1904 $year > 2040 $month < 1 $month > 12 $day < 1 $day > 31 $hour < 0 $hour > 23 $min < 0 $min > 59 $sec < 0 $sec > 59
Truth table0%0/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $year < 1904B= $year > 2040C= $month < 1D= $month > 12E= $day < 1F= $day > 31G= $hour < 0H= $hour > 23I= $min < 0J= $min > 59K= $sec < 0L= $sec > 59
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
2039 (
2040 ($year < 1904) or ($year > 2040) or
2041 ($month < 1) or ($month > 12) or
2042 ($day < 1) or ($day > 31) or
2043 ($hour < 0) or ($hour > 23) or
2044 ($min < 0) or ($min > 59) or
2045 ($sec < 0) or ($sec > 59)
2046 );
2047 0 ▶ return 0 if
Branch: 1 branch
BranchTrueFalseTotal
if $year == 2040 and $month > 2 || $month == 2 && ($day > 6 || $day == 6 && ($hour > 6 || $hour == 6 && ($min > 28 || $min == 28 && $sec > 15))) 0 0 0
Condition0%0/27
$year == 2040 and $month > 2 || $month == 2 && ($day > 6 || $day == 6 && ($hour > 6 || $hour == 6 && ($min > 28 || $min == 28 && $sec > 15)))
!ll&&!rl&&r
000
$month > 2 or $month == 2 and $day > 6 || $day == 6 && ($hour > 6 || $hour == 6 && ($min > 28 || $min == 28 && $sec > 15))
l!l&&r!l&&!r
000
$month == 2 and $day > 6 || $day == 6 && ($hour > 6 || $hour == 6 && ($min > 28 || $min == 28 && $sec > 15))
!ll&&!rl&&r
000
$day > 6 or $day == 6 and $hour > 6 || $hour == 6 && ($min > 28 || $min == 28 && $sec > 15)
l!l&&r!l&&!r
000
$day == 6 and $hour > 6 || $hour == 6 && ($min > 28 || $min == 28 && $sec > 15)
!ll&&!rl&&r
000
$hour > 6 or $hour == 6 and $min > 28 || $min == 28 && $sec > 15
l!l&&r!l&&!r
000
$hour == 6 and $min > 28 || $min == 28 && $sec > 15
!ll&&!rl&&r
000
$min > 28 or $min == 28 and $sec > 15
l!l&&r!l&&!r
000
$min == 28 and $sec > 15
!ll&&!rl&&r
000
MC/DC0%0/10
$year == 2040 and $month > 2 || $month == 2 && ($day > 6 || $day == 6 && ($hour > 6 || $hour == 6 && ($min > 28 || $min == 28 && $sec > 15)))
$year == 2040 $month > 2 $month == 2 $day > 6 $day == 6 $hour > 6 $hour == 6 $min > 28 $min == 28 $sec > 15
Truth table0%0/11
A and B or C and D or E and F or G and H or I and J
A= $year == 2040B= $month > 2C= $month == 2D= $day > 6E= $day == 6F= $hour > 6G= $hour == 6H= $min > 28I= $min == 28J= $sec > 15
ABCDEFGHIJresult
0XXXXXXXXX0
100XXXXXXX0
10100XXXXX0
1010100XXX0
101010100X0
10101010100
11XXXXXXXX1
1011XXXXXX1
101011XXXX1
10101011XX1
10101010111
2048 (
2049 ($year == 2040) and ( ($month > 2) or
2050 ( ($month == 2) and ( ($day > 6) or
2051 ( ($day == 6) and ( ($hour > 6) or
2052 ( ($hour == 6) and ( ($min > 28) or
2053 ( ($min == 28) and ($sec > 15) ) )))))))
2054 );
2055 }
2056 else
2057 {
2058 2 ▶ return 0 if
Branch: 1 branch
BranchTrueFalseTotal
if $year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59 or $sec < 0 or $sec > 59 0 2 2
Condition33%11/33
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59 or $sec < 0 or $sec > 59
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59 or $sec < 0
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1 or $month > 12
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038 or $month < 1
l!l&&r!l&&!r
002
$year < 1970 or $year > 2038
l!l&&r!l&&!r
002
MC/DC0%0/12
$year < 1970 or $year > 2038 or $month < 1 or $month > 12 or $day < 1 or $day > 31 or $hour < 0 or $hour > 23 or $min < 0 or $min > 59 or $sec < 0 or $sec > 59
$year < 1970 $year > 2038 $month < 1 $month > 12 $day < 1 $day > 31 $hour < 0 $hour > 23 $min < 0 $min > 59 $sec < 0 $sec > 59
Truth table7%1/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $year < 1970B= $year > 2038C= $month < 1D= $month > 12E= $day < 1F= $day > 31G= $hour < 0H= $hour > 23I= $min < 0J= $min > 59K= $sec < 0L= $sec > 59
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
2059 (
2060 ($year < 1970) or ($year > 2038) or
2061 ($month < 1) or ($month > 12) or
2062 ($day < 1) or ($day > 31) or
2063 ($hour < 0) or ($hour > 23) or
2064 ($min < 0) or ($min > 59) or
2065 ($sec < 0) or ($sec > 59)
2066 );
2067 2 ▶ return 0 if
Branch: 1 branch
BranchTrueFalseTotal
if $year == 2038 and $month > 1 || $month == 1 && ($day > 19 || $day == 19 && ($hour > 3 || $hour == 3 && ($min > 14 || $min == 14 && $sec > 7))) 0 2 2
Condition3%1/27
$year == 2038 and $month > 1 || $month == 1 && ($day > 19 || $day == 19 && ($hour > 3 || $hour == 3 && ($min > 14 || $min == 14 && $sec > 7)))
!ll&&!rl&&r
200
$month > 1 or $month == 1 and $day > 19 || $day == 19 && ($hour > 3 || $hour == 3 && ($min > 14 || $min == 14 && $sec > 7))
l!l&&r!l&&!r
000
$month == 1 and $day > 19 || $day == 19 && ($hour > 3 || $hour == 3 && ($min > 14 || $min == 14 && $sec > 7))
!ll&&!rl&&r
000
$day > 19 or $day == 19 and $hour > 3 || $hour == 3 && ($min > 14 || $min == 14 && $sec > 7)
l!l&&r!l&&!r
000
$day == 19 and $hour > 3 || $hour == 3 && ($min > 14 || $min == 14 && $sec > 7)
!ll&&!rl&&r
000
$hour > 3 or $hour == 3 and $min > 14 || $min == 14 && $sec > 7
l!l&&r!l&&!r
000
$hour == 3 and $min > 14 || $min == 14 && $sec > 7
!ll&&!rl&&r
000
$min > 14 or $min == 14 and $sec > 7
l!l&&r!l&&!r
000
$min == 14 and $sec > 7
!ll&&!rl&&r
000
MC/DC0%0/10
$year == 2038 and $month > 1 || $month == 1 && ($day > 19 || $day == 19 && ($hour > 3 || $hour == 3 && ($min > 14 || $min == 14 && $sec > 7)))
$year == 2038 $month > 1 $month == 1 $day > 19 $day == 19 $hour > 3 $hour == 3 $min > 14 $min == 14 $sec > 7
Truth table9%1/11
A and B or C and D or E and F or G and H or I and J
A= $year == 2038B= $month > 1C= $month == 1D= $day > 19E= $day == 19F= $hour > 3G= $hour == 3H= $min > 14I= $min == 14J= $sec > 7
ABCDEFGHIJresult
0XXXXXXXXX0
100XXXXXXX0
10100XXXXX0
1010100XXX0
101010100X0
10101010100
11XXXXXXXX1
1011XXXXXX1
101011XXXX1
10101011XX1
10101010111
2068 (
2069 ($year == 2038) and ( ($month > 1) or
2070 ( ($month == 1) and ( ($day > 19) or
2071 ( ($day == 19) and ( ($hour > 3) or
2072 ( ($hour == 3) and ( ($min > 14) or
2073 ( ($min == 14) and ($sec > 7) ) )))))))
2074 );
2075 }
2076 2 $year -= 1900;
2077 2 $month--;
2078 2 ▶ if ($doy <= 0) { $doy = -1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($doy <= 0) { } 2 0 2
2079 0 else { $doy--; }
2080 2 ▶ if ($dow <= 0) { $dow = -1; }
Branch: 2 branches
BranchTrueFalseTotal
if ($dow <= 0) { } 2 0 2
elsif ($dow == 7) { } 0 0 0
2081 0 elsif ($dow == 7) { $dow = 0; }
2082 2 ▶ if ($dst != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($dst != 0) 2 0 2
2083 {
2084 2 ▶ if ($dst < 0) { $dst = -1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($dst < 0) { } 2 0 2
2085 0 else { $dst = 1; }
2086 }
2087 2 ▶ $$_seconds = POSIX::mktime($sec,$min,$hour,$day,$month,$year,$doy,$dow,$dst) || 0;
Condition50%1/2
POSIX::mktime($sec, $min, $hour, $day, $month, $year, $doy, $dow, $dst) || 0
l!l
20
MC/DC0%0/1
POSIX::mktime($sec, $min, $hour, $day, $month, $year, $doy, $dow, $dst) || 0
POSIX::mktime($sec, $min, $hour, $day, $month, $year, $doy, $dow, $dst)
Truth table50%1/2
A
A= POSIX::mktime($sec, $min, $hour, $day, $month, $year, $doy, $dow, $dst)
Aresult
11
00
2088 2 ▶ return 1 if ($$_seconds >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $$_seconds >= 0 2 0 2
2089 0 return 0;
2090 }
2091  
2092 sub DateCalc_timezone
2093 0 ▶{
Subroutine DateCalc_timezone: not called CC=5 SCAR=34.0
Pod undocumented
2094 0 my($_year,$_month,$_day,$_hour,$_min,$_sec,$_dst,$when) = @_;
2095 0 my($year1,$month1,$day1,$hour1,$min1,$sec1,$year2,$month2,$day2,$hour2,$min2,$sec2);
2096 0 ▶ if ($when >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($when >= 0) 0 0 0
2097 {
2098 0 ($year1,$month1,$day1,$hour1,$min1,$sec1) = (gmtime($when))[5,4,3,2,1,0];
2099 0 $year1 += 1900;
2100 0 $month1++;
2101 0 ($year2,$month2,$day2,$hour2,$min2,$sec2,$$_dst) = (localtime($when))[5,4,3,2,1,0,8];
2102 0 $year2 += 1900;
2103 0 $month2++;
2104 0 ▶ if (DateCalc_delta_ymdhms($_year,$_month,$_day, $_hour,$_min,$_sec,
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_delta_ymdhms($_year, $_month, $_day, $_hour, $_min, $_sec, $year1, $month1, $day1, $hour1, $min1, $sec1, $year2, $month2, $day2, $hour2, $min2, $sec2)) 0 0 0
2105 $year1,$month1,$day1, $hour1,$min1,$sec1,
2106 $year2,$month2,$day2, $hour2,$min2,$sec2))
2107 {
2108 0 ▶ if ($$_dst != 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_dst != 0) 0 0 0
2109 {
2110 0 ▶ if ($$_dst < 0) { $$_dst = -1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($$_dst < 0) { } 0 0 0
2111 0 else { $$_dst = 1; }
2112 }
2113 0 return 1;
2114 }
2115 }
2116 0 return 0;
2117 }
2118  
2119 ## MacOS (Classic): ##
2120 ## <695056.0> = Fri 1-Jan-1904 00:00:00 (time=0x00000000) ##
2121 ## <744766.23295> = Mon 6-Feb-2040 06:28:15 (time=0xFFFFFFFF) ##
2122  
2123 ## Unix: ##
2124 ## <719163.0> = Thu 1-Jan-1970 00:00:00 (time=0x00000000) ##
2125 ## <744018.11647> = Tue 19-Jan-2038 03:14:07 (time=0x7FFFFFFF) ##
2126  
2127 #ifdef MACOS_TRADITIONAL
2128 #define DateCalc_DAYS_TO_EPOCH 695056
2129 #define DateCalc_DAYS_TO_OVFLW 744766
2130 #define DateCalc_SECS_TO_OVFLW 23295
2131 #else
2132 #define DateCalc_DAYS_TO_EPOCH 719163
2133 #define DateCalc_DAYS_TO_OVFLW 744018
2134 #define DateCalc_SECS_TO_OVFLW 11647
2135 #endif
2136  
2137 ## Substitute for BSD's timegm(3) function: ##
2138  
2139 sub DateCalc_date2time
2140 6 ▶{
Subroutine DateCalc_date2time: called CC=6 SCAR=20.5
Pod undocumented
2141 6 my($_seconds,$year,$month,$day,$hour,$min,$sec) = @_;
2142 6 my($days,$secs);
2143 6 $$_seconds = 0;
2144 6 $days = DateCalc_Date_to_Days($year,$month,$day);
2145 6 $secs = ((($hour * 60) + $min) * 60) + $sec;
2146 6 ▶ return 0 if
Branch: 1 branch
BranchTrueFalseTotal
if $days < $DateCalc_DAYS_TO_EPOCH or $secs < 0 or $days > $DateCalc_DAYS_TO_OVFLW or $days == $DateCalc_DAYS_TO_OVFLW and $secs > $DateCalc_SECS_TO_OVFLW 0 6 6
Condition41%5/12
$days < $DateCalc_DAYS_TO_EPOCH or $secs < 0 or $days > $DateCalc_DAYS_TO_OVFLW or $days == $DateCalc_DAYS_TO_OVFLW and $secs > $DateCalc_SECS_TO_OVFLW
l!l&&r!l&&!r
006
$days < $DateCalc_DAYS_TO_EPOCH or $secs < 0 or $days > $DateCalc_DAYS_TO_OVFLW
l!l&&r!l&&!r
006
$days < $DateCalc_DAYS_TO_EPOCH or $secs < 0
l!l&&r!l&&!r
006
$days == $DateCalc_DAYS_TO_OVFLW and $secs > $DateCalc_SECS_TO_OVFLW
!ll&&!rl&&r
420
MC/DC0%0/5
$days < $DateCalc_DAYS_TO_EPOCH or $secs < 0 or $days > $DateCalc_DAYS_TO_OVFLW or $days == $DateCalc_DAYS_TO_OVFLW and $secs > $DateCalc_SECS_TO_OVFLW
$days < $DateCalc_DAYS_TO_EPOCH $secs < 0 $days > $DateCalc_DAYS_TO_OVFLW $days == $DateCalc_DAYS_TO_OVFLW $secs > $DateCalc_SECS_TO_OVFLW
Truth table33%2/6
A or B or C or D and E
A= $days < $DateCalc_DAYS_TO_EPOCHB= $secs < 0C= $days > $DateCalc_DAYS_TO_OVFLWD= $days == $DateCalc_DAYS_TO_OVFLWE= $secs > $DateCalc_SECS_TO_OVFLW
ABCDEresult
1XXXX1
01XXX1
001XX1
000111
0000X0
000100
2147 (
2148 ($days < $DateCalc_DAYS_TO_EPOCH) or
2149 ($secs < 0) or
2150 ($days > $DateCalc_DAYS_TO_OVFLW) or
2151 (
2152 ($days == $DateCalc_DAYS_TO_OVFLW) and
2153 ($secs > $DateCalc_SECS_TO_OVFLW)
2154 )
2155 );
2156 6 $$_seconds = (($days - $DateCalc_DAYS_TO_EPOCH) * 86400) + $secs;
2157 6 return 1;
2158 }
2159  
2160 ## Substitute for POSIX's gmtime(3) function: ##
2161  
2162 sub DateCalc_time2date
2163 8 ▶{
Subroutine DateCalc_time2date: called CC=2 SCAR=6.9
Pod undocumented
2164 8 my($_year,$_month,$_day,$_hour,$_min,$_sec,$ss) = @_;
2165 8 my($mm,$hh,$dd);
2166 8 ▶ return 0 if ($ss < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $ss < 0 0 8 8
2167 8 $dd = int($ss / 86400);
2168 8 $ss -= $dd * 86400;
2169 8 $mm = int($ss / 60);
2170 8 $ss -= $mm * 60;
2171 8 $hh = int($mm / 60);
2172 8 $mm -= $hh * 60;
2173 8 $dd += $DateCalc_DAYS_TO_EPOCH-1;
2174 8 $$_sec = $ss;
2175 8 $$_min = $mm;
2176 8 $$_hour = $hh;
2177 8 $$_day = 1;
2178 8 $$_month = 1;
2179 8 $$_year = 1;
2180 8 return DateCalc_add_delta_days($_year,$_month,$_day,$dd);
2181 }
2182  
2183 sub DateCalc_easter_sunday
2184 910 ▶{
Subroutine DateCalc_easter_sunday: called CC=16 SCAR=27.7
Pod undocumented
2185 ##**************************************************************##
2186 ## ##
2187 ## Gauss'sche Regel (Gaussian Rule) ##
2188 ## ================================ ##
2189 ## ##
2190 ## Quelle / Source: ##
2191 ## ##
2192 ## H. H. Voigt, "Abriss der Astronomie", Wissenschaftsverlag, ##
2193 ## Bibliographisches Institut, Seite 9. ##
2194 ## ##
2195 ##**************************************************************##
2196  
2197 910 my($_year,$_month,$_day) = @_;
2198 910 my($a,$b,$c,$d,$e,$m,$n);
2199  
2200 910 ▶ return 0 if (($$_year < 1583) or ($$_year > 2299));
Branch: 1 branch
BranchTrueFalseTotal
if $$_year < 1583 or $$_year > 2299 2 908 910
Condition100%3/3
$$_year < 1583 or $$_year > 2299
l!l&&r!l&&!r
11908
MC/DC100%2/2
$$_year < 1583 or $$_year > 2299
$$_year < 1583 $$_year > 2299
Truth table100%3/3
A or B
A= $$_year < 1583B= $$_year > 2299
ABresult
1X1
011
000
2201  
2202 908 ▶ if ($$_year < 1700) { $m = 22; $n = 2; }
Branch: 5 branches
BranchTrueFalseTotal
if ($$_year < 1700) { } 117 791 908
elsif ($$_year < 1800) { } 100 691 791
elsif ($$_year < 1900) { } 100 591 691
elsif ($$_year < 2100) { } 391 200 591
elsif ($$_year < 2200) { } 100 100 200
2203 100 elsif ($$_year < 1800) { $m = 23; $n = 3; }
2204 100 elsif ($$_year < 1900) { $m = 23; $n = 4; }
2205 391 elsif ($$_year < 2100) { $m = 24; $n = 5; }
2206 100 elsif ($$_year < 2200) { $m = 24; $n = 6; }
2207 100 else { $m = 25; $n = 0; }
2208  
2209 908 $a = $$_year % 19;
2210 908 $b = $$_year % 4;
2211 908 $c = $$_year % 7;
2212 908 $d = (19 * $a + $m) % 30;
2213 908 $e = (2 * $b + 4 * $c + 6 * $d + $n) % 7;
2214 908 $$_day = 22 + $d + $e;
2215 908 $$_month = 3;
2216 908 ▶ if ($$_day > 31)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_day > 31) 741 167 908
2217 {
2218 741 $$_day -= 31; ## same as $$_day = $d + $e - 9; ##
2219 741 ${$_month}++;
2220 }
2221 908 ▶ $$_day = 19 if (($$_day == 26) and ($$_month == 4));
Branch: 1 branch
BranchTrueFalseTotal
if $$_day == 26 and $$_month == 4 6 902 908
Condition100%3/3
$$_day == 26 and $$_month == 4
!ll&&!rl&&r
880226
MC/DC100%2/2
$$_day == 26 and $$_month == 4
$$_day == 26 $$_month == 4
Truth table100%3/3
A and B
A= $$_day == 26B= $$_month == 4
ABresult
0X0
100
111
2222 908 ▶ $$_day = 18 if (($$_day == 25) and ($$_month == 4) and ($d == 28) and ($e == 6) and ($a > 10));
Branch: 1 branch
BranchTrueFalseTotal
if $$_day == 25 and $$_month == 4 and $d == 28 and $e == 6 and $a > 10 3 905 908
Condition91%11/12
$$_day == 25 and $$_month == 4 and $d == 28 and $e == 6 and $a > 10
!ll&&!rl&&r
90323
$$_day == 25 and $$_month == 4 and $d == 28 and $e == 6
!ll&&!rl&&r
90305
$$_day == 25 and $$_month == 4 and $d == 28
!ll&&!rl&&r
89855
$$_day == 25 and $$_month == 4
!ll&&!rl&&r
8841410
MC/DC80%4/5
$$_day == 25 and $$_month == 4 and $d == 28 and $e == 6 and $a > 10
$$_day == 25 $$_month == 4 $d == 28 $e == 6 $a > 10
Truth table83%5/6
A and B and C and D and E
A= $$_day == 25B= $$_month == 4C= $d == 28D= $e == 6E= $a > 10
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
2223 908 return 1;
2224 }
2225  
2226 ## Carnival Monday / Rosenmontag / Veille du Mardi Gras = easter sunday - 48 ##
2227 ## Mardi Gras / Karnevalsdienstag / Mardi Gras = easter sunday - 47 ##
2228 ## Ash Wednesday / Aschermittwoch / Mercredi des Cendres = easter sunday - 46 ##
2229 ## Palm Sunday / Palmsonntag / Dimanche des Rameaux = easter sunday - 7 ##
2230 ## Easter Friday / Karfreitag / Vendredi Saint = easter sunday - 2 ##
2231 ## Easter Saturday / Ostersamstag / Samedi de Paques = easter sunday - 1 ##
2232 ## Easter Monday / Ostermontag / Lundi de Paques = easter sunday + 1 ##
2233 ## Ascension of Christ / Christi Himmelfahrt / Ascension = easter sunday + 39 ##
2234 ## Whitsunday / Pfingstsonntag / Dimanche de Pentecote = easter sunday + 49 ##
2235 ## Whitmonday / Pfingstmontag / Lundi de Pentecote = easter sunday + 50 ##
2236 ## Feast of Corpus Christi / Fronleichnam / Fete-Dieu = easter sunday + 60 ##
2237  
2238 sub DateCalc_Decode_Month ## 0 = error ##
2239 2121 ▶{
Subroutine DateCalc_Decode_Month: called CC=8 SCAR=20.8
Pod undocumented
2240 2121 my($string,$lang) = @_;
2241 2121 my($length,$buffer,$month,$ok,$m);
2242 2121 ▶ $lang = $DateCalc_Language if (($lang < 1) or ($lang > $DateCalc_LANGUAGES));
Branch: 1 branch
BranchTrueFalseTotal
if $lang < 1 or $lang > $DateCalc_LANGUAGES 900 1221 2121
Condition66%2/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
90001221
MC/DC50%1/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table66%2/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
2243 2121 $length = length($string);
2244 2121 $buffer = DateCalc_ISO_UC($string);
2245 2121 $month = 0;
2246 2121 $ok = 0;
2247 MONTH:
2248 2121 ▶ for ( $m = 1; $m <= 12; $m++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($m <= 12) 25376 2108 27484
2249 {
2250 25376 ▶ next MONTH if ($length > length($DateCalc_Month_to_Text_[$lang][$m]));
Branch: 1 branch
BranchTrueFalseTotal
if $length > length $DateCalc_Month_to_Text_[$lang][$m] 117 25259 25376
2251 25259 ▶ next MONTH if (DateCalc_ISO_UC(substr($DateCalc_Month_to_Text_[$lang][$m],0,$length)) ne $buffer);
Branch: 1 branch
BranchTrueFalseTotal
if DateCalc_ISO_UC(substr($DateCalc_Month_to_Text_[$lang][$m], 0, $length)) ne $buffer 23129 2130 25259
2252 2130 ▶ if ($month > 0) { $ok = 0; last MONTH; }
Branch: 1 branch
BranchTrueFalseTotal
if ($month > 0) { } 13 2117 2130
2253 2117 else { $ok = 1; $month = $m; }
2254 }
2255 2121 ▶ return $month if ($ok);
Branch: 1 branch
BranchTrueFalseTotal
if $ok 2104 17 2121
2256 17 return 0;
2257 }
2258  
2259 sub DateCalc_Decode_Day_of_Week ## 0 = error ##
2260 1187 ▶{
Subroutine DateCalc_Decode_Day_of_Week: called CC=8 SCAR=20.8
Pod undocumented
2261 1187 my($string,$lang) = @_;
2262 1187 my($length,$buffer,$dow,$ok,$d);
2263 1187 ▶ $lang = $DateCalc_Language if (($lang < 1) or ($lang > $DateCalc_LANGUAGES));
Branch: 1 branch
BranchTrueFalseTotal
if $lang < 1 or $lang > $DateCalc_LANGUAGES 35 1152 1187
Condition66%2/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
3501152
MC/DC50%1/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table66%2/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
2264 1187 $length = length($string);
2265 1187 $buffer = DateCalc_ISO_UC($string);
2266 1187 $dow = 0;
2267 1187 $ok = 0;
2268 DAYOFWEEK:
2269 1187 ▶ for ( $d = 1; $d <= 7; $d++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($d <= 7) 8303 1183 9486
2270 {
2271 8303 ▶ next DAYOFWEEK if ($length > length($DateCalc_Day_of_Week_to_Text_[$lang][$d]));
Branch: 1 branch
BranchTrueFalseTotal
if $length > length $DateCalc_Day_of_Week_to_Text_[$lang][$d] 37 8266 8303
2272 8266 ▶ next DAYOFWEEK if (DateCalc_ISO_UC(substr($DateCalc_Day_of_Week_to_Text_[$lang][$d],0,$length)) ne $buffer);
Branch: 1 branch
BranchTrueFalseTotal
if DateCalc_ISO_UC(substr($DateCalc_Day_of_Week_to_Text_[$lang][$d], 0, $length)) ne $buffer 7081 1185 8266
2273 1185 ▶ if ($dow > 0) { $ok = 0; last DAYOFWEEK; }
Branch: 1 branch
BranchTrueFalseTotal
if ($dow > 0) { } 4 1181 1185
2274 1181 else { $ok = 1; $dow = $d; }
2275 }
2276 1187 ▶ return $dow if ($ok);
Branch: 1 branch
BranchTrueFalseTotal
if $ok 1177 10 1187
2277 10 return 0;
2278 }
2279  
2280 sub DateCalc_Decode_Language ## 0 = error ##
2281 10 ▶{
Subroutine DateCalc_Decode_Language: called CC=6 SCAR=18.3
Pod undocumented
2282 10 my($string) = $_[0];
2283 10 my($length,$buffer,$lang,$ok,$l);
2284 10 $length = length($string);
2285 10 $buffer = DateCalc_ISO_UC($string);
2286 10 $lang = 0;
2287 10 $ok = 0;
2288 LANGUAGE:
2289 10 ▶ for ( $l = 1; $l <= $DateCalc_LANGUAGES; $l++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($l <= $DateCalc_LANGUAGES) 140 10 150
2290 {
2291 140 ▶ next LANGUAGE if ($length > length($DateCalc_Language_to_Text_[$l]));
Branch: 1 branch
BranchTrueFalseTotal
if $length > length $DateCalc_Language_to_Text_[$l] 16 124 140
2292 124 ▶ next LANGUAGE if (DateCalc_ISO_UC(substr($DateCalc_Language_to_Text_[$l],0,$length)) ne $buffer);
Branch: 1 branch
BranchTrueFalseTotal
if DateCalc_ISO_UC(substr($DateCalc_Language_to_Text_[$l], 0, $length)) ne $buffer 114 10 124
2293 0 ▶ if ($lang > 0) { $ok = 0; last LANGUAGE; }
Branch: 1 branch
BranchTrueFalseTotal
if ($lang > 0) { } 0 10 10
2294 10 else { $ok = 1; $lang = $l; }
2295 }
2296 10 ▶ return $lang if ($ok);
Branch: 1 branch
BranchTrueFalseTotal
if $ok 10 0 10
2297 0 return 0;
2298 }
2299  
2300 sub DateCalc_decode_date_eu
2301 14 ▶{
Subroutine DateCalc_decode_date_eu: called CC=23 SCAR=34.5
Pod undocumented
2302 14 my($string,$_year,$_month,$_day,$lang) = @_;
2303 14 my($length,$buffer,$i,$j);
2304 14 ▶ $lang = $DateCalc_Language if (($lang < 1) or ($lang > $DateCalc_LANGUAGES));
Branch: 1 branch
BranchTrueFalseTotal
if $lang < 1 or $lang > $DateCalc_LANGUAGES 11 3 14
Condition66%2/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
1103
MC/DC50%1/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table66%2/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
2305 14 $$_year = $$_month = $$_day = 0;
2306 14 ▶ return 0 unless ($length = length($string));
Branch: 1 branch
BranchTrueFalseTotal
unless $length = length $string 0 14 14
2307 14 $buffer = 0;
2308 14 $i = 0;
2309 14 ▶ while (DateCalc_scan9($string,$buffer,$length,$i,1)) { $i++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $i, 1)) 12 14 26
2310 14 $j = $length-1;
2311 14 ▶ while (DateCalc_scan9($string,$buffer,$length,$j,1)) { $j--; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $j, 1)) 24 14 38
2312 14 ▶ if ($i+1 < $j) ## at least 3 chars, else error! ##
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 1 < $j) { } 14 0 14
2313 {
2314 14 $buffer += $i;
2315 14 $length = $j-$i+1;
2316 14 $i = 1;
2317 14 ▶ while (DateCalc_scan9($string,$buffer,$length,$i,0)) { $i++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $i, 0)) 13 14 27
2318 14 $j = $length-2;
2319 14 ▶ while (DateCalc_scan9($string,$buffer,$length,$j,0)) { $j--; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $j, 0)) 28 14 42
2320 14 ▶ if ($j < $i) ## only numerical chars without delimiters ##
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) { } 2 12 14
2321 {
2322 2 ▶ if ($length == 3)
Branch: 6 branches
BranchTrueFalseTotal
if ($length == 3) { } 0 2 2
elsif ($length == 4) { } 1 1 2
elsif ($length == 5) { } 0 1 1
elsif ($length == 6) { } 1 0 1
elsif ($length == 7) { } 0 0 0
elsif ($length == 8) { } 0 0 0
2323 {
2324 0 $$_day = substr($string,$buffer, 1);
2325 0 $$_month = substr($string,$buffer+1,1);
2326 0 $$_year = substr($string,$buffer+2,1);
2327 }
2328 elsif ($length == 4)
2329 {
2330 1 $$_day = substr($string,$buffer, 1);
2331 1 $$_month = substr($string,$buffer+1,1);
2332 1 $$_year = substr($string,$buffer+2,2);
2333 }
2334 elsif ($length == 5)
2335 {
2336 0 $$_day = substr($string,$buffer, 1);
2337 0 $$_month = substr($string,$buffer+1,2);
2338 0 $$_year = substr($string,$buffer+3,2);
2339 }
2340 elsif ($length == 6)
2341 {
2342 1 $$_day = substr($string,$buffer, 2);
2343 1 $$_month = substr($string,$buffer+2,2);
2344 1 $$_year = substr($string,$buffer+4,2);
2345 }
2346 elsif ($length == 7)
2347 {
2348 0 $$_day = substr($string,$buffer, 1);
2349 0 $$_month = substr($string,$buffer+1,2);
2350 0 $$_year = substr($string,$buffer+3,4);
2351 }
2352 elsif ($length == 8)
2353 {
2354 0 $$_day = substr($string,$buffer, 2);
2355 0 $$_month = substr($string,$buffer+2,2);
2356 0 $$_year = substr($string,$buffer+4,4);
2357 }
2358 0 else { return 0; }
2359 }
2360 else ## at least one non-numerical char (i <= j) ##
2361 {
2362 12 $$_day = substr($string,$buffer,$i);
2363 12 $$_year = substr($string,$buffer+($j+1),$length-($j+1));
2364 12 ▶ while (DateCalc_scanx($string,$buffer,$length,$i,1)) { $i++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scanx($string, $buffer, $length, $i, 1)) 12 12 24
2365 12 ▶ while (DateCalc_scanx($string,$buffer,$length,$j,1)) { $j--; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scanx($string, $buffer, $length, $j, 1)) 10 12 22
2366 12 ▶ if ($i <= $j) ## at least one char left for month ##
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $j) { } 12 0 12
2367 {
2368 12 $buffer += $i;
2369 12 $length = $j-$i+1;
2370 12 $i = 1;
2371 12 ▶ while (DateCalc_scanx($string,$buffer,$length,$i,0)) { $i++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scanx($string, $buffer, $length, $i, 0)) 16 12 28
2372 12 ▶ if ($i >= $length) ## ok, no more delimiters ##
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= $length) { } 12 0 12
2373 {
2374 12 $i = 0;
2375 12 ▶ while (DateCalc_scan9($string,$buffer,$length,$i,0)) { $i++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $i, 0)) 8 12 20
2376 12 ▶ if ($i >= $length) ## only digits for month ##
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= $length) { } 6 6 12
2377 {
2378 6 $$_month = substr($string,$buffer,$length);
2379 }
2380 else ## match with month names ##
2381 {
2382 6 $$_month = DateCalc_Decode_Month(substr($string,$buffer,$length),$lang);
2383 }
2384 }
2385 0 else { return 0; } ## delimiters inside month string ##
2386 }
2387 0 else { return 0; } ## no chars left for month ##
2388 } ## at least one non-numerical char (i <= j) ##
2389 }
2390 0 else { return 0; } ## less than 3 chars in buffer ##
2391 14 $$_year = DateCalc_Moving_Window($$_year);
2392 14 return DateCalc_check_date($$_year,$$_month,$$_day);
2393 }
2394  
2395 sub DateCalc_decode_date_us
2396 11 ▶{
Subroutine DateCalc_decode_date_us: called CC=35 SCAR=49.3
Pod undocumented
2397 11 my($string,$_year,$_month,$_day,$lang) = @_;
2398 11 my($length,$buffer,$i,$j,$k);
2399 11 ▶ $lang = $DateCalc_Language if (($lang < 1) or ($lang > $DateCalc_LANGUAGES));
Branch: 1 branch
BranchTrueFalseTotal
if $lang < 1 or $lang > $DateCalc_LANGUAGES 11 0 11
Condition33%1/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
1100
MC/DC0%0/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table33%1/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
2400  
2401 11 $$_year = $$_month = $$_day = 0;
2402 11 ▶ return 0 unless ($length = length($string));
Branch: 1 branch
BranchTrueFalseTotal
unless $length = length $string 0 11 11
2403 {
2404 11 $buffer = 0;
2405 11 $i = 0;
2406 11 ▶ while (DateCalc_scanx($string,$buffer,$length,$i,1)) { $i++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scanx($string, $buffer, $length, $i, 1)) 5 11 16
2407 11 $j = $length-1;
2408 11 ▶ while (DateCalc_scan9($string,$buffer,$length,$j,1)) { $j--; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $j, 1)) 11 11 22
2409 11 ▶ if ($i+1 < $j) ## at least 3 chars, else error! ##
Branch: 1 branch
BranchTrueFalseTotal
if ($i + 1 < $j) { } 11 0 11
2410 {
2411 11 $buffer += $i;
2412 11 $length = $j-$i+1;
2413 11 $i = 1;
2414 11 ▶ while (DateCalc_scanx($string,$buffer,$length,$i,0)) { $i++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scanx($string, $buffer, $length, $i, 0)) 30 11 41
2415 11 $j = $length-2;
2416 11 ▶ while (DateCalc_scan9($string,$buffer,$length,$j,0)) { $j--; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $j, 0)) 26 11 37
2417 11 ▶ if ($i >= $length) ## only alphanumeric chars left ##
Branch: 1 branch
BranchTrueFalseTotal
if ($i >= $length) { } 4 7 11
2418 {
2419 4 ▶ if ($j < 0) ## case 0 : xxxx999999xxxx ##
Branch: 1 branch
BranchTrueFalseTotal
if ($j < 0) { } 1 3 4
2420 { ## j0 i ##
2421 1 ▶ if ($length == 3)
Branch: 6 branches
BranchTrueFalseTotal
if ($length == 3) { } 0 1 1
elsif ($length == 4) { } 1 0 1
elsif ($length == 5) { } 0 0 0
elsif ($length == 6) { } 0 0 0
elsif ($length == 7) { } 0 0 0
elsif ($length == 8) { } 0 0 0
2422 {
2423 0 $$_month = substr($string,$buffer, 1);
2424 0 $$_day = substr($string,$buffer+1,1);
2425 0 $$_year = substr($string,$buffer+2,1);
2426 }
2427 elsif ($length == 4)
2428 {
2429 1 $$_month = substr($string,$buffer, 1);
2430 1 $$_day = substr($string,$buffer+1,1);
2431 1 $$_year = substr($string,$buffer+2,2);
2432 }
2433 elsif ($length == 5)
2434 {
2435 0 $$_month = substr($string,$buffer, 1);
2436 0 $$_day = substr($string,$buffer+1,2);
2437 0 $$_year = substr($string,$buffer+3,2);
2438 }
2439 elsif ($length == 6)
2440 {
2441 0 $$_month = substr($string,$buffer, 2);
2442 0 $$_day = substr($string,$buffer+2,2);
2443 0 $$_year = substr($string,$buffer+4,2);
2444 }
2445 elsif ($length == 7)
2446 {
2447 0 $$_month = substr($string,$buffer, 1);
2448 0 $$_day = substr($string,$buffer+1,2);
2449 0 $$_year = substr($string,$buffer+3,4);
2450 }
2451 elsif ($length == 8)
2452 {
2453 0 $$_month = substr($string,$buffer, 2);
2454 0 $$_day = substr($string,$buffer+2,2);
2455 0 $$_year = substr($string,$buffer+4,4);
2456 }
2457 0 else { return 0; }
2458 }
2459 else ## case 1 : xxxxAAA999999xxxx ##
2460 { ## 0 j i ##
2461 3 $$_month = DateCalc_Decode_Month(substr($string,$buffer,$j+1),$lang);
2462 3 $buffer += $j+1;
2463 3 $length -= $j+1;
2464 3 ▶ if ($length == 2)
Branch: 5 branches
BranchTrueFalseTotal
if ($length == 2) { } 0 3 3
elsif ($length == 3) { } 2 1 3
elsif ($length == 4) { } 0 1 1
elsif ($length == 5) { } 1 0 1
elsif ($length == 6) { } 0 0 0
2465 {
2466 0 $$_day = substr($string,$buffer, 1);
2467 0 $$_year = substr($string,$buffer+1,1);
2468 }
2469 elsif ($length == 3)
2470 {
2471 2 $$_day = substr($string,$buffer, 1);
2472 2 $$_year = substr($string,$buffer+1,2);
2473 }
2474 elsif ($length == 4)
2475 {
2476 0 $$_day = substr($string,$buffer, 2);
2477 0 $$_year = substr($string,$buffer+2,2);
2478 }
2479 elsif ($length == 5)
2480 {
2481 1 $$_day = substr($string,$buffer, 1);
2482 1 $$_year = substr($string,$buffer+1,4);
2483 }
2484 elsif ($length == 6)
2485 {
2486 0 $$_day = substr($string,$buffer, 2);
2487 0 $$_year = substr($string,$buffer+2,4);
2488 }
2489 0 else { return 0; }
2490 }
2491 } ## 0 i j l ##
2492 else ## case 2 : xxxxAAAxxxx9999xxxx _OR_ ##
2493 { ## case 3 : xxxxAAAxx99xx9999xx ##
2494 7 $k = 0; ## 0 i j l ##
2495 7 ▶ while (DateCalc_scan9($string,$buffer,$length,$k,0)) { $k++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $k, 0)) 5 7 12
2496 7 ▶ if ($k >= $i) ## ok, only digits ##
Branch: 1 branch
BranchTrueFalseTotal
if ($k >= $i) { } 4 3 7
2497 {
2498 4 $$_month = substr($string,$buffer,$i);
2499 }
2500 else ## no, some non-digits ##
2501 {
2502 3 $$_month = DateCalc_Decode_Month(substr($string,$buffer,$i),$lang);
2503 0 ▶ if ($$_month == 0) { return 0; }
Branch: 1 branch
BranchTrueFalseTotal
if ($$_month == 0) 0 3 3
2504 }
2505 7 $buffer += $i;
2506 7 $length -= $i;
2507 7 $j -= $i;
2508 7 $k = $j+1; ## remember start position of day+year(2)/year(3) ##
2509 7 $i = 1;
2510 0 ▶ while (DateCalc_scanx($string,$buffer,$length,$i,1)) { $i++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scanx($string, $buffer, $length, $i, 1)) 0 7 7
2511 7 $j--;
2512 7 ▶ while (DateCalc_scan9($string,$buffer,$length,$j,1)) { $j--; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $j, 1)) 3 7 10
2513 7 ▶ if ($j < $i) ## case 2 : xxxxAAAxxxx9999xxxx ##
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) { } 0 7 7
2514 { ## j0 i l ##
2515 0 $buffer += $k; ## k ##
2516 0 $length -= $k;
2517 0 ▶ if ($length == 2)
Branch: 5 branches
BranchTrueFalseTotal
if ($length == 2) { } 0 0 0
elsif ($length == 3) { } 0 0 0
elsif ($length == 4) { } 0 0 0
elsif ($length == 5) { } 0 0 0
elsif ($length == 6) { } 0 0 0
2518 {
2519 0 $$_day = substr($string,$buffer, 1);
2520 0 $$_year = substr($string,$buffer+1,1);
2521 }
2522 elsif ($length == 3)
2523 {
2524 0 $$_day = substr($string,$buffer, 1);
2525 0 $$_year = substr($string,$buffer+1,2);
2526 }
2527 elsif ($length == 4)
2528 {
2529 0 $$_day = substr($string,$buffer, 2);
2530 0 $$_year = substr($string,$buffer+2,2);
2531 }
2532 elsif ($length == 5)
2533 {
2534 0 $$_day = substr($string,$buffer, 1);
2535 0 $$_year = substr($string,$buffer+1,4);
2536 }
2537 elsif ($length == 6)
2538 {
2539 0 $$_day = substr($string,$buffer, 2);
2540 0 $$_year = substr($string,$buffer+2,4);
2541 }
2542 0 else { return 0; }
2543 }
2544 else ## case 3 : xxxxAAAxx99xx9999xx ##
2545 { ## 0 ij k l ##
2546 7 $$_year = substr($string,$buffer+$k,$length-$k);
2547 7 $k = $i;
2548 7 ▶ while (DateCalc_scan9($string,$buffer,$length,$k,0)) { $k++; }
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_scan9($string, $buffer, $length, $k, 0)) 10 7 17
2549 7 ▶ if ($k > $j) ## ok, only digits ##
Branch: 1 branch
BranchTrueFalseTotal
if ($k > $j) { } 7 0 7
2550 {
2551 7 $$_day = substr($string,$buffer+$i,$j-$i+1);
2552 }
2553 0 else { return 0; } ## non-digits inside day ##
2554 }
2555 } ## i < length ##
2556 }
2557 0 else { return 0; } ## less than 3 chars in buffer ##
2558 }
2559 11 $$_year = DateCalc_Moving_Window($$_year);
2560 11 return DateCalc_check_date($$_year,$$_month,$$_day);
2561 }
2562  
2563 sub DateCalc_Fixed_Window
2564 0 ▶{
Subroutine DateCalc_Fixed_Window: not called CC=4 SCAR=30.0
Pod undocumented
2565 0 my($year) = $_[0];
2566 0 ▶ return 0 if ($year < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $year < 0 0 0 0
2567 0 ▶ if ($year < 100)
Branch: 1 branch
BranchTrueFalseTotal
if ($year < 100) 0 0 0
2568 {
2569 0 ▶ $year += 100 if ($year < $DateCalc_YEAR_OF_EPOCH);
Branch: 1 branch
BranchTrueFalseTotal
if $year < $DateCalc_YEAR_OF_EPOCH 0 0 0
2570 0 $year += $DateCalc_CENTURY_OF_EPOCH;
2571 }
2572 0 return $year;
2573 }
2574  
2575 sub DateCalc_Moving_Window
2576 109 ▶{
Subroutine DateCalc_Moving_Window: called CC=6 SCAR=19.5
Pod undocumented
2577 109 my($year) = $_[0];
2578 109 my($seconds,$current,$century);
2579 109 ▶ return 0 if ($year < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $year < 0 0 109 109
2580 109 ▶ if ($year < 100)
Branch: 1 branch
BranchTrueFalseTotal
if ($year < 100) 68 41 109
2581 {
2582 68 ▶ if (($seconds = time()) >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (($seconds = time) >= 0) { } 68 0 68
2583 {
2584 68 $current = (gmtime($seconds))[5] + 1900;
2585 68 $century = int($current / 100);
2586 68 $year += $century * 100;
2587 0 ▶ if ($year < $current - 50) { $year += 100; }
Branch: 2 branches
BranchTrueFalseTotal
if ($year < $current - 50) { } 0 68 68
elsif ($year >= $current + 50) { } 0 68 68
2588 0 elsif ($year >= $current + 50) { $year -= 100; }
2589 }
2590 0 else { $year = DateCalc_Fixed_Window($year); }
2591 }
2592 109 return $year;
2593 }
2594  
2595 sub DateCalc_Compress
2596 6 ▶{
Subroutine DateCalc_Compress: called CC=10 SCAR=23.5
Pod undocumented
2597 6 my($year,$month,$day) = @_;
2598 6 my($yy);
2599 6 ▶ if (($year >= $DateCalc_EPOCH) and ($year < ($DateCalc_EPOCH + 100)))
Branch: 1 branch
BranchTrueFalseTotal
if ($year >= $DateCalc_EPOCH and $year < $DateCalc_EPOCH + 100) { } 3 3 6
Condition66%2/3
$year >= $DateCalc_EPOCH and $year < $DateCalc_EPOCH + 100
!ll&&!rl&&r
303
MC/DC50%1/2
$year >= $DateCalc_EPOCH and $year < $DateCalc_EPOCH + 100
$year >= $DateCalc_EPOCH $year < $DateCalc_EPOCH + 100
Truth table66%2/3
A and B
A= $year >= $DateCalc_EPOCHB= $year < $DateCalc_EPOCH + 100
ABresult
0X0
100
111
2600 {
2601 3 $yy = $year;
2602 3 $year -= $DateCalc_EPOCH;
2603 }
2604 else
2605 {
2606 3 ▶ return 0 if (($year < 0) or ($year > 99));
Branch: 1 branch
BranchTrueFalseTotal
if $year < 0 or $year > 99 1 2 3
Condition66%2/3
$year < 0 or $year > 99
l!l&&r!l&&!r
012
MC/DC50%1/2
$year < 0 or $year > 99
$year < 0 $year > 99
Truth table66%2/3
A or B
A= $year < 0B= $year > 99
ABresult
1X1
011
000
2607 2 ▶ if ($year < $DateCalc_YEAR_OF_EPOCH)
Branch: 1 branch
BranchTrueFalseTotal
if ($year < $DateCalc_YEAR_OF_EPOCH) { } 1 1 2
2608 {
2609 1 $yy = $DateCalc_CENTURY_OF_EPOCH + 100 + $year;
2610 1 $year += 100 - $DateCalc_YEAR_OF_EPOCH;
2611 }
2612 else
2613 {
2614 1 $yy = $DateCalc_CENTURY_OF_EPOCH + $year;
2615 1 $year -= $DateCalc_YEAR_OF_EPOCH;
2616 }
2617 }
2618 5 ▶ return 0 if (($month < 1) or ($month > 12));
Branch: 1 branch
BranchTrueFalseTotal
if $month < 1 or $month > 12 0 5 5
Condition33%1/3
$month < 1 or $month > 12
l!l&&r!l&&!r
005
MC/DC0%0/2
$month < 1 or $month > 12
$month < 1 $month > 12
Truth table33%1/3
A or B
A= $month < 1B= $month > 12
ABresult
1X1
011
000
2619 5 ▶ return 0 if
Branch: 1 branch
BranchTrueFalseTotal
if $day < 1 or $day > $DateCalc_Days_in_Month_[DateCalc_leap_year($yy)][$month] 1 4 5
Condition66%2/3
$day < 1 or $day > $DateCalc_Days_in_Month_[DateCalc_leap_year($yy)][$month]
l!l&&r!l&&!r
014
MC/DC50%1/2
$day < 1 or $day > $DateCalc_Days_in_Month_[DateCalc_leap_year($yy)][$month]
$day < 1 $day > $DateCalc_Days_in_Month_[DateCalc_leap_year($yy)][$month]
Truth table66%2/3
A or B
A= $day < 1B= $day > $DateCalc_Days_in_Month_[DateCalc_leap_year($yy)][$month]
ABresult
1X1
011
000
2620 (($day < 1) or
2621 ($day > $DateCalc_Days_in_Month_[DateCalc_leap_year($yy)][$month]));
2622 4 return ($year << 9) | ($month << 5) | $day;
2623 }
2624  
2625 sub DateCalc_uncompress
2626 30 ▶{
Subroutine DateCalc_uncompress: called CC=4 SCAR=13.9
Pod undocumented
2627 30 my($date,$_century,$_year,$_month,$_day) = @_;
2628 30 ▶ if ($date > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($date > 0) 24 6 30
2629 {
2630 24 $$_year = $date >> 9;
2631 24 $$_month = ($date & 0x01FF) >> 5;
2632 24 $$_day = $date & 0x001F;
2633 24 ▶ if ($$_year < 100)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_year < 100) 24 0 24
2634 {
2635 24 ▶ if ($$_year < 100-$DateCalc_YEAR_OF_EPOCH)
Branch: 1 branch
BranchTrueFalseTotal
if ($$_year < 100 - $DateCalc_YEAR_OF_EPOCH) { } 18 6 24
2636 {
2637 18 $$_century = $DateCalc_CENTURY_OF_EPOCH;
2638 18 $$_year += $DateCalc_YEAR_OF_EPOCH;
2639 }
2640 else
2641 {
2642 6 $$_century = $DateCalc_CENTURY_OF_EPOCH+100;
2643 6 $$_year -= 100-$DateCalc_YEAR_OF_EPOCH;
2644 }
2645 24 return DateCalc_check_date($$_century+$$_year,$$_month,$$_day);
2646 }
2647 }
2648 6 return 0;
2649 }
2650  
2651 sub DateCalc_check_compressed
2652 5 ▶{
Subroutine DateCalc_check_compressed: called CC=1 SCAR=0.0
Pod undocumented
2653 5 my($century,$year,$month,$day);
2654 5 return DateCalc_uncompress($_[0],\$century,\$year,\$month,\$day);
2655 }
2656  
2657 sub DateCalc_Compressed_to_Text
2658 20 ▶{
Subroutine DateCalc_Compressed_to_Text: called CC=4 SCAR=13.9
Pod undocumented
2659 20 my($date,$lang) = @_;
2660 20 my($century,$year,$month,$day,$string);
2661 20 ▶ $lang = $DateCalc_Language if (($lang < 1) or ($lang > $DateCalc_LANGUAGES));
Branch: 1 branch
BranchTrueFalseTotal
if $lang < 1 or $lang > $DateCalc_LANGUAGES 10 10 20
Condition66%2/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
10010
MC/DC50%1/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table66%2/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
2662 20 ▶ if (DateCalc_uncompress($date,\$century,\$year,\$month,\$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_uncompress($date, \$century, \$year, \$month, \$day)) { } 12 8 20
2663 {
2664 12 $string = sprintf("%02d-%.3s-%02d",$day,$DateCalc_Month_to_Text_[$lang][$month],$year);
2665 }
2666 8 else { $string = '??-???-??'; }
2667 20 return $string;
2668 }
2669  
2670 sub DateCalc_Date_to_Text
2671 9 ▶{
Subroutine DateCalc_Date_to_Text: called CC=5 SCAR=17.5
Pod undocumented
2672 9 my($year,$month,$day,$lang) = @_;
2673 9 ▶ $lang = $DateCalc_Language if (($lang < 1) or ($lang > $DateCalc_LANGUAGES));
Branch: 1 branch
BranchTrueFalseTotal
if $lang < 1 or $lang > $DateCalc_LANGUAGES 4 5 9
Condition66%2/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
405
MC/DC50%1/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table66%2/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
2674 9 ▶ if (DateCalc_check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year, $month, $day)) 9 0 9
2675 {
2676 9 ▶ if ($DateCalc_Day_of_Week_Abbreviation_[$lang][0] ne '')
Branch: 1 branch
BranchTrueFalseTotal
if ($DateCalc_Day_of_Week_Abbreviation_[$lang][0] ne '') { } 0 9 9
2677 {
2678 0 return sprintf("%.3s %d-%.3s-%d",
2679 $DateCalc_Day_of_Week_Abbreviation_[$lang][DateCalc_Day_of_Week($year,$month,$day)],
2680 $day,$DateCalc_Month_to_Text_[$lang][$month],$year);
2681 }
2682 else
2683 {
2684 9 return sprintf("%.3s %d-%.3s-%d",
2685 $DateCalc_Day_of_Week_to_Text_[$lang][DateCalc_Day_of_Week($year,$month,$day)],
2686 $day,$DateCalc_Month_to_Text_[$lang][$month],$year);
2687 }
2688 }
2689 0 return undef;
2690 }
2691  
2692 sub DateCalc_English_Ordinal
2693 13 ▶{
Subroutine DateCalc_English_Ordinal: called CC=6 SCAR=18.0
Pod undocumented
2694 13 my($result) = "$_[0]";
2695 13 my($length,$digit);
2696 13 ▶ if (($length = length($result)) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (($length = length $result) > 0) 13 0 13
2697 {
2698 13 ▶ $digit = 0 unless
Branch: 1 branch
BranchTrueFalseTotal
unless $length > 1 && substr($result, $length - 2, 1) ne 1 || $length == 1 and ($digit = substr($result, $length - 1, 1)) <= 3 4 9 13
Condition88%8/9
$length > 1 && substr($result, $length - 2, 1) ne 1 || $length == 1 and ($digit = substr($result, $length - 1, 1)) <= 3
!ll&&!rl&&r
409
$length > 1 and substr($result, $length - 2, 1) ne 1 or $length == 1
l!l&&r!l&&!r
274
$length > 1 and substr($result, $length - 2, 1) ne 1
!ll&&!rl&&r
742
MC/DC25%1/4
$length > 1 && substr($result, $length - 2, 1) ne 1 || $length == 1 and ($digit = substr($result, $length - 1, 1)) <= 3
$length > 1 substr($result, $length - 2, 1) ne 1 $length == 1 ($digit = substr($result, $length - 1, 1)) <= 3
Truth table37%3/8
A and B or C and D
A= $length > 1B= substr($result, $length - 2, 1) ne 1C= $length == 1D= ($digit = substr($result, $length - 1, 1)) <= 3
ABCDresult
0X0X0
100X0
11X00
0X100
10100
11X11
0X111
10111
2699 (
2700 ( (($length > 1) and (substr($result,$length-2,1) ne '1')) or ($length == 1) )
2701 and
2702 ( ($digit = substr($result,$length-1,1)) <= 3 )
2703 );
2704 13 $result .= $DateCalc_English_Ordinals_[$digit];
2705 }
2706 13 return $result;
2707 }
2708  
2709 sub DateCalc_Date_to_Text_Long
2710 55 ▶{
Subroutine DateCalc_Date_to_Text_Long: called CC=6 SCAR=18.8
Pod undocumented
2711 55 my($year,$month,$day,$lang) = @_;
2712 55 my($string,$buffer);
2713 55 ▶ $lang = $DateCalc_Language if (($lang < 1) or ($lang > $DateCalc_LANGUAGES));
Branch: 1 branch
BranchTrueFalseTotal
if $lang < 1 or $lang > $DateCalc_LANGUAGES 20 35 55
Condition66%2/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
20035
MC/DC50%1/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table66%2/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
2714 55 ▶ if (DateCalc_check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (DateCalc_check_date($year, $month, $day)) 55 0 55
2715 {
2716 55 ▶ if ($lang == 1)
Branch: 2 branches
BranchTrueFalseTotal
if ($lang == 1) { } 13 42 55
elsif ($lang == 12) { } 0 42 42
2717 {
2718 13 return sprintf
2719 (
2720 $DateCalc_Date_Long_Format_[$lang],
2721 $DateCalc_Day_of_Week_to_Text_[$lang]
2722 [DateCalc_Day_of_Week($year,$month,$day)],
2723 $DateCalc_Month_to_Text_[$lang][$month],
2724 DateCalc_English_Ordinal($day),
2725 $year
2726 );
2727 }
2728 elsif ($lang == 12)
2729 {
2730 0 return sprintf
2731 (
2732 $DateCalc_Date_Long_Format_[$lang],
2733 $year,
2734 $DateCalc_Month_to_Text_[$lang][$month],
2735 $day,
2736 $DateCalc_Day_of_Week_to_Text_[$lang]
2737 [DateCalc_Day_of_Week($year,$month,$day)]
2738 );
2739 }
2740 else
2741 {
2742 42 return sprintf
2743 (
2744 $DateCalc_Date_Long_Format_[$lang],
2745 $DateCalc_Day_of_Week_to_Text_[$lang]
2746 [DateCalc_Day_of_Week($year,$month,$day)],
2747 $day,
2748 $DateCalc_Month_to_Text_[$lang][$month],
2749 $year
2750 );
2751 }
2752 }
2753 0 return undef;
2754 }
2755  
2756 sub DateCalc_Calendar
2757 24 ▶{
Subroutine DateCalc_Calendar: called CC=12 SCAR=25.4
Pod undocumented
2758 24 my($year,$month,$orthodox,$lang) = @_;
2759 24 my($string,$cursor,$buffer,$first,$last,$day);
2760 24 ▶ if (($lang < 1) or ($lang > $DateCalc_LANGUAGES)) { $lang = $DateCalc_Language; }
Branch: 1 branch
BranchTrueFalseTotal
if ($lang < 1 or $lang > $DateCalc_LANGUAGES) 24 0 24
Condition33%1/3
$lang < 1 or $lang > $DateCalc_LANGUAGES
l!l&&r!l&&!r
2400
MC/DC0%0/2
$lang < 1 or $lang > $DateCalc_LANGUAGES
$lang < 1 $lang > $DateCalc_LANGUAGES
Truth table33%1/3
A or B
A= $lang < 1B= $lang > $DateCalc_LANGUAGES
ABresult
1X1
011
000
2761 24 $string = '';
2762 24 $cursor = \$string;
2763 24 DateCalc_Newline($cursor,1);
2764 24 $buffer = sprintf("%s %d", DateCalc_ISO_UC_First($DateCalc_Month_to_Text_[$lang][$month]), $year);
2765 24 DateCalc_Center($cursor,$buffer,27);
2766 24 ▶ if ($DateCalc_Day_of_Week_Abbreviation_[$lang][0] ne '')
Branch: 1 branch
BranchTrueFalseTotal
if ($DateCalc_Day_of_Week_Abbreviation_[$lang][0] ne '') { } 0 24 24
2767 {
2768 0 ▶ if ($orthodox)
Branch: 1 branch
BranchTrueFalseTotal
if ($orthodox) { } 0 0 0
2769 {
2770 0 $string .= sprintf("%3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s\n",
2771 $DateCalc_Day_of_Week_Abbreviation_[$lang][7],
2772 $DateCalc_Day_of_Week_Abbreviation_[$lang][1],
2773 $DateCalc_Day_of_Week_Abbreviation_[$lang][2],
2774 $DateCalc_Day_of_Week_Abbreviation_[$lang][3],
2775 $DateCalc_Day_of_Week_Abbreviation_[$lang][4],
2776 $DateCalc_Day_of_Week_Abbreviation_[$lang][5],
2777 $DateCalc_Day_of_Week_Abbreviation_[$lang][6]);
2778 }
2779 else ## conform to ISO standard ##
2780 {
2781 0 $string .= sprintf("%3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s\n",
2782 $DateCalc_Day_of_Week_Abbreviation_[$lang][1],
2783 $DateCalc_Day_of_Week_Abbreviation_[$lang][2],
2784 $DateCalc_Day_of_Week_Abbreviation_[$lang][3],
2785 $DateCalc_Day_of_Week_Abbreviation_[$lang][4],
2786 $DateCalc_Day_of_Week_Abbreviation_[$lang][5],
2787 $DateCalc_Day_of_Week_Abbreviation_[$lang][6],
2788 $DateCalc_Day_of_Week_Abbreviation_[$lang][7]);
2789 }
2790 }
2791 else
2792 {
2793 24 ▶ if ($orthodox)
Branch: 1 branch
BranchTrueFalseTotal
if ($orthodox) { } 12 12 24
2794 {
2795 12 $string .= sprintf("%3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s\n",
2796 $DateCalc_Day_of_Week_to_Text_[$lang][7],
2797 $DateCalc_Day_of_Week_to_Text_[$lang][1],
2798 $DateCalc_Day_of_Week_to_Text_[$lang][2],
2799 $DateCalc_Day_of_Week_to_Text_[$lang][3],
2800 $DateCalc_Day_of_Week_to_Text_[$lang][4],
2801 $DateCalc_Day_of_Week_to_Text_[$lang][5],
2802 $DateCalc_Day_of_Week_to_Text_[$lang][6]);
2803 }
2804 else ## conform to ISO standard ##
2805 {
2806 12 $string .= sprintf("%3.3s %3.3s %3.3s %3.3s %3.3s %3.3s %3.3s\n",
2807 $DateCalc_Day_of_Week_to_Text_[$lang][1],
2808 $DateCalc_Day_of_Week_to_Text_[$lang][2],
2809 $DateCalc_Day_of_Week_to_Text_[$lang][3],
2810 $DateCalc_Day_of_Week_to_Text_[$lang][4],
2811 $DateCalc_Day_of_Week_to_Text_[$lang][5],
2812 $DateCalc_Day_of_Week_to_Text_[$lang][6],
2813 $DateCalc_Day_of_Week_to_Text_[$lang][7]);
2814 }
2815 }
2816 24 $first = DateCalc_Day_of_Week($year,$month,1);
2817 24 $last = $DateCalc_Days_in_Month_[DateCalc_leap_year($year)][$month];
2818 24 ▶ if ($orthodox) { $first = 0 if ($first == 7); }
Branch: 2 branches
BranchTrueFalseTotal
if ($orthodox) { } 12 12 24
if $first == 7 1 11 12
2819 12 else { $first--; }
2820 24 ▶ if ($first) { DateCalc_Blank($cursor,($first<<2)-1); }
Branch: 1 branch
BranchTrueFalseTotal
if ($first) 20 4 24
2821 24 ▶ for ( $day = 1; $day <= $last; $day++, $first++ )
Branch: 1 branch
BranchTrueFalseTotal
if ($day <= $last) 731 24 755
2822 {
2823 731 ▶ if ($first > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($first > 0) 727 4 731
2824 {
2825 727 ▶ if ($first > 6)
Branch: 1 branch
BranchTrueFalseTotal
if ($first > 6) { } 101 626 727
2826 {
2827 101 $first = 0;
2828 101 DateCalc_Newline($cursor,1);
2829 }
2830 626 else { DateCalc_Blank($cursor,1); }
2831 }
2832 731 $string .= sprintf(" %2d",$day);
2833 }
2834 24 DateCalc_Newline($cursor,2);
2835 24 return $string;
2836 }
2837  
2838 ###############
2839 ## ##
2840 ## Calc.pm ##
2841 ## ##
2842 ###############
2843  
2844 sub Decode_Date_EU2
2845 46 ▶{
Subroutine Decode_Date_EU2: called CC=17 SCAR=28.3
Pod undocumented
2846 46 ▶ croak "Usage: (\$year,\$month,\$day) = Decode_Date_EU2(\$date[,\$lang]);\n" unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 46 46
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
3970
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
2847  
2848 46 my($buffer) = shift;
2849 46 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
442
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
2850 46 my($year,$month,$day,$length);
2851  
2852 46 ▶ $lang = Language() unless (($lang >= 1) and ($lang <= Languages()));
Branch: 1 branch
BranchTrueFalseTotal
unless $lang >= 1 and $lang <= Languages() 42 4 46
Condition66%2/3
$lang >= 1 and $lang <= Languages()
!ll&&!rl&&r
4204
MC/DC50%1/2
$lang >= 1 and $lang <= Languages()
$lang >= 1 $lang <= Languages()
Truth table66%2/3
A and B
A= $lang >= 1B= $lang <= Languages()
ABresult
0X0
100
111
2853 46 ▶ if ($buffer =~ /^\D* (\d+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* (\d+) \D*$/x)
Branch: 3 branches
BranchTrueFalseTotal
if ($buffer =~ /^\D* (\d+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* (\d+) \D*$/x) { } 22 24 46
elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x) { } 19 5 24
elsif ($buffer =~ /^\D* (\d+) \D+ (\d+) \D+ (\d+) \D*$/x) { } 3 2 5
2854 {
2855 22 ($day,$month,$year) = ($1,$2,$3);
2856 22 $month = Decode_Month($month,$lang);
2857 22 ▶ unless ($month > 0)
Branch: 1 branch
BranchTrueFalseTotal
unless ($month > 0) 1 21 22
2858 {
2859 1 return(); # can't decode month!
2860 }
2861 }
2862 elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x)
2863 {
2864 19 $buffer = $1;
2865 19 $length = length($buffer);
2866 19 ▶ if ($length == 3)
Branch: 6 branches
BranchTrueFalseTotal
if ($length == 3) { } 3 16 19
elsif ($length == 4) { } 3 13 16
elsif ($length == 5) { } 3 10 13
elsif ($length == 6) { } 3 7 10
elsif ($length == 7) { } 3 4 7
elsif ($length == 8) { } 3 1 4
2867 {
2868 3 $day = substr($buffer,0,1);
2869 3 $month = substr($buffer,1,1);
2870 3 $year = substr($buffer,2,1);
2871 }
2872 elsif ($length == 4)
2873 {
2874 3 $day = substr($buffer,0,1);
2875 3 $month = substr($buffer,1,1);
2876 3 $year = substr($buffer,2,2);
2877 }
2878 elsif ($length == 5)
2879 {
2880 3 $day = substr($buffer,0,1);
2881 3 $month = substr($buffer,1,2);
2882 3 $year = substr($buffer,3,2);
2883 }
2884 elsif ($length == 6)
2885 {
2886 3 $day = substr($buffer,0,2);
2887 3 $month = substr($buffer,2,2);
2888 3 $year = substr($buffer,4,2);
2889 }
2890 elsif ($length == 7)
2891 {
2892 3 $day = substr($buffer,0,1);
2893 3 $month = substr($buffer,1,2);
2894 3 $year = substr($buffer,3,4);
2895 }
2896 elsif ($length == 8)
2897 {
2898 3 $day = substr($buffer,0,2);
2899 3 $month = substr($buffer,2,2);
2900 3 $year = substr($buffer,4,4);
2901 }
2902 1 else { return(); } # wrong number of digits!
2903 }
2904 elsif ($buffer =~ /^\D* (\d+) \D+ (\d+) \D+ (\d+) \D*$/x)
2905 {
2906 3 ($day,$month,$year) = ($1,$2,$3);
2907 }
2908 2 else { return(); } # no match at all!
2909 42 $year = Moving_Window($year);
2910 42 ▶ if (check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (check_date($year, $month, $day)) { } 40 2 42
2911 {
2912 40 return($year,$month,$day);
2913 }
2914 2 else { return(); } # not a valid date!
2915 }
2916  
2917 sub Decode_Date_US2
2918 46 ▶{
Subroutine Decode_Date_US2: called CC=24 SCAR=32.0
Pod undocumented
2919 46 ▶ croak "Usage: (\$year,\$month,\$day) = Decode_Date_US2(\$date[,\$lang]);\n" unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 46 46
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
3970
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
2920  
2921 46 my($buffer) = shift;
2922 46 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
442
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
2923 46 my($year,$month,$day,$length);
2924  
2925 46 ▶ $lang = Language() unless (($lang >= 1) and ($lang <= Languages()));
Branch: 1 branch
BranchTrueFalseTotal
unless $lang >= 1 and $lang <= Languages() 42 4 46
Condition66%2/3
$lang >= 1 and $lang <= Languages()
!ll&&!rl&&r
4204
MC/DC50%1/2
$lang >= 1 and $lang <= Languages()
$lang >= 1 $lang <= Languages()
Truth table66%2/3
A and B
A= $lang >= 1B= $lang <= Languages()
ABresult
0X0
100
111
2926 46 ▶ if ($buffer =~ /^[^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* 0*(\d+) \D*$/x)
Branch: 4 branches
BranchTrueFalseTotal
if ($buffer =~ /^[^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* 0*(\d+) \D*$/x) { } 14 32 46
elsif ($buffer =~ /^[^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* (\d+) \D+ (\d+) \D*$/x) { } 8 24 32
elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x) { } 19 5 24
elsif ($buffer =~ /^\D* (\d+) \D+ (\d+) \D+ (\d+) \D*$/x) { } 3 2 5
2927 {
2928 14 ($month,$buffer) = ($1,$2);
2929 14 $month = Decode_Month($month,$lang);
2930 14 ▶ unless ($month > 0)
Branch: 1 branch
BranchTrueFalseTotal
unless ($month > 0) 0 14 14
2931 {
2932 0 return(); # can't decode month!
2933 }
2934 14 $length = length($buffer);
2935 14 ▶ if ($length == 2)
Branch: 5 branches
BranchTrueFalseTotal
if ($length == 2) { } 0 14 14
elsif ($length == 3) { } 3 11 14
elsif ($length == 4) { } 4 7 11
elsif ($length == 5) { } 3 4 7
elsif ($length == 6) { } 4 0 4
2936 {
2937 0 $day = substr($buffer,0,1);
2938 0 $year = substr($buffer,1,1);
2939 }
2940 elsif ($length == 3)
2941 {
2942 3 $day = substr($buffer,0,1);
2943 3 $year = substr($buffer,1,2);
2944 }
2945 elsif ($length == 4)
2946 {
2947 4 $day = substr($buffer,0,2);
2948 4 $year = substr($buffer,2,2);
2949 }
2950 elsif ($length == 5)
2951 {
2952 3 $day = substr($buffer,0,1);
2953 3 $year = substr($buffer,1,4);
2954 }
2955 elsif ($length == 6)
2956 {
2957 4 $day = substr($buffer,0,2);
2958 4 $year = substr($buffer,2,4);
2959 }
2960 0 else { return(); } # wrong number of digits!
2961 }
2962 elsif ($buffer =~ /^[^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* (\d+) \D+ (\d+) \D*$/x)
2963 {
2964 8 ($month,$day,$year) = ($1,$2,$3);
2965 8 $month = Decode_Month($month,$lang);
2966 8 ▶ unless ($month > 0)
Branch: 1 branch
BranchTrueFalseTotal
unless ($month > 0) 1 7 8
2967 {
2968 1 return(); # can't decode month!
2969 }
2970 }
2971 elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x)
2972 {
2973 19 $buffer = $1;
2974 19 $length = length($buffer);
2975 19 ▶ if ($length == 3)
Branch: 6 branches
BranchTrueFalseTotal
if ($length == 3) { } 3 16 19
elsif ($length == 4) { } 3 13 16
elsif ($length == 5) { } 3 10 13
elsif ($length == 6) { } 3 7 10
elsif ($length == 7) { } 3 4 7
elsif ($length == 8) { } 3 1 4
2976 {
2977 3 $month = substr($buffer,0,1);
2978 3 $day = substr($buffer,1,1);
2979 3 $year = substr($buffer,2,1);
2980 }
2981 elsif ($length == 4)
2982 {
2983 3 $month = substr($buffer,0,1);
2984 3 $day = substr($buffer,1,1);
2985 3 $year = substr($buffer,2,2);
2986 }
2987 elsif ($length == 5)
2988 {
2989 3 $month = substr($buffer,0,1);
2990 3 $day = substr($buffer,1,2);
2991 3 $year = substr($buffer,3,2);
2992 }
2993 elsif ($length == 6)
2994 {
2995 3 $month = substr($buffer,0,2);
2996 3 $day = substr($buffer,2,2);
2997 3 $year = substr($buffer,4,2);
2998 }
2999 elsif ($length == 7)
3000 {
3001 3 $month = substr($buffer,0,1);
3002 3 $day = substr($buffer,1,2);
3003 3 $year = substr($buffer,3,4);
3004 }
3005 elsif ($length == 8)
3006 {
3007 3 $month = substr($buffer,0,2);
3008 3 $day = substr($buffer,2,2);
3009 3 $year = substr($buffer,4,4);
3010 }
3011 1 else { return(); } # wrong number of digits!
3012 }
3013 elsif ($buffer =~ /^\D* (\d+) \D+ (\d+) \D+ (\d+) \D*$/x)
3014 {
3015 3 ($month,$day,$year) = ($1,$2,$3);
3016 }
3017 2 else { return(); } # no match at all!
3018 42 $year = Moving_Window($year);
3019 42 ▶ if (check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
if (check_date($year, $month, $day)) { } 40 2 42
3020 {
3021 40 return($year,$month,$day);
3022 }
3023 2 else { return(); } # not a valid date!
3024 }
3025  
3026 sub Parse_Date
3027 15 ▶{
Subroutine Parse_Date: called CC=10 SCAR=23.3
Pod undocumented
3028 15 ▶ croak "Usage: (\$year,\$month,\$day) = Parse_Date(\$date[,\$lang]);\n" unless ((@_ == 1) or (@_ == 2));
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 or @_ == 2 0 15 15
Condition66%2/3
@_ == 1 or @_ == 2
l!l&&r!l&&!r
1050
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1 @_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
ABresult
1X1
011
000
3029  
3030 15 my($date) = shift;
3031 15 ▶ my($lang) = shift || 0;
Condition100%2/2
shift() || 0
l!l
411
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
3032 15 my($year,$month,$day);
3033  
3034 15 ▶ $lang = Language() unless (($lang >= 1) and ($lang <= Languages()));
Branch: 1 branch
BranchTrueFalseTotal
unless $lang >= 1 and $lang <= Languages() 11 4 15
Condition66%2/3
$lang >= 1 and $lang <= Languages()
!ll&&!rl&&r
1104
MC/DC50%1/2
$lang >= 1 and $lang <= Languages()
$lang >= 1 $lang <= Languages()
Truth table66%2/3
A and B
A= $lang >= 1B= $lang <= Languages()
ABresult
0X0
100
111
3035 15 ▶ unless ($date =~ /\b([\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF]{3})\s+([0123]??\d)\b/)
Branch: 1 branch
BranchTrueFalseTotal
unless ($date =~ /\b([\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF]{3})\s+([0123]??\d)\b/) 1 14 15
3036 {
3037 1 return();
3038 }
3039 14 $month = $1;
3040 14 $day = $2;
3041 14 ▶ unless ($date =~ /\b(19\d\d|20\d\d)\b/)
Branch: 1 branch
BranchTrueFalseTotal
unless ($date =~ /\b(19\d\d|20\d\d)\b/) 1 13 14
3042 {
3043 1 return();
3044 }
3045 13 $year = $1;
3046 13 $month = Decode_Month($month,$lang);
3047 13 ▶ unless ($month > 0)
Branch: 1 branch
BranchTrueFalseTotal
unless ($month > 0) 0 13 13
3048 {
3049 0 return();
3050 }
3051 13 ▶ unless (check_date($year,$month,$day))
Branch: 1 branch
BranchTrueFalseTotal
unless (check_date($year, $month, $day)) 1 12 13
3052 {
3053 1 return();
3054 }
3055 12 return($year,$month,$day);
3056 }
3057  
3058 50 1;
3059  
3060 __END__
↑ Summary Calc/Object.pm »