| 1 | package Time::Precise; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Time::HiRes; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK $PRECISION ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use subs qw(localtime gmtime time sleep ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | $VERSION = '1.0016'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | @EXPORT = qw(time localtime gmtime sleep timegm timelocal is_valid_date is_leap_year time_hashref gmtime_hashref get_time_from get_gmtime_from localtime_ts gmtime_ts); | |||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | $PRECISION = 7; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | my @MonthDays = ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | my $month_duration = { | |||||||||||||||||||||||||||||||||||||||||
| 19 | 1 => 31, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 => 28, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 => 31, | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 4 => 30, | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 => 31, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 => 30, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 => 31, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 => 31, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 9 => 30, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | 10 => 31, | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 11 => 30, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | 12 => 31, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # Determine breakpoint for rolling century | ||||||||||||||||||||||||||||||||||||||||||
| 34 | #my $ThisYear = ( localtime() )[5]; | ||||||||||||||||||||||||||||||||||||||||||
| 35 | #my $Breakpoint = ( $ThisYear + 50 ) % 100; | ||||||||||||||||||||||||||||||||||||||||||
| 36 | #my $NextCentury = $ThisYear - $ThisYear % 100; | ||||||||||||||||||||||||||||||||||||||||||
| 37 | #$NextCentury += 100 if $Breakpoint < 50; | ||||||||||||||||||||||||||||||||||||||||||
| 38 | #my $Century = $NextCentury - 100; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | my $SecOff = 0; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | my ( %Options, %Cheat ); | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 2 | ▶ | use constant SECS_PER_MINUTE => 60; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | ▶ | use constant SECS_PER_HOUR => 3600; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | use constant SECS_PER_DAY => 86400; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | my $MaxDay; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | ▶ | if ($] < 5.012000) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my $MaxInt; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ( $^O eq 'MacOS' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | # time_t is unsigned... | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $MaxInt = ( 1 << ( 8 * $Config{ivsize} ) ) - 1; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $MaxInt = ( ( 1 << ( 8 * $Config{ivsize} - 2 ) ) - 1 ) * 2 + 1; | |||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $MaxDay = int( ( $MaxInt - ( SECS_PER_DAY / 2 ) ) / SECS_PER_DAY ) - 1; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | # recent localtime()'s limit is the year 2**31 | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | $MaxDay = 365 * (2**47); # Supported at least on 5.014 x64 | |||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | # Determine the EPOC day for this machine | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | my $Epoc = 0; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | ▶ | if ( $^O eq 'vos' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | # work around posix-977 -- VOS doesn't handle dates in the range | ||||||||||||||||||||||||||||||||||||||||||
| 69 | # 1970-1980. | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $Epoc = _daygm( 0, 0, 0, 1, 0, 70, 4, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | elsif ( $^O eq 'MacOS' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $MaxDay *=2 if $^O eq 'MacOS'; # time_t unsigned ... quick hack? | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | # MacOS time() is seconds since 1 Jan 1904, localtime | ||||||||||||||||||||||||||||||||||||||||||
| 75 | # so we need to calculate an offset to apply later | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $Epoc = 693901; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $SecOff = timelocal( localtime(0)) - timelocal( gmtime(0) ) ; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $Epoc += _daygm( gmtime(0) ); | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | $Epoc = _daygm( gmtime(0) ); | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | %Cheat = (); # clear the cache as epoc has changed | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | ▶ | sub time () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | ▶ | return CORE::time unless $PRECISION; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | return sprintf '%0.'.$PRECISION.'f', Time::HiRes::time(); | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 11 | ▶ | sub _localtime { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_localtime: called CC=10 SCAR=23.5
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 11 | my $gm = shift; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 11 | my $arg = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 11 | ▶ | if ($arg < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | croak "Negative seconds require a Perl version >= 5.012" unless $] >= 5.012; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 11 | ▶ | $arg = time unless defined $arg; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 11 | $arg = sprintf '%.'.$PRECISION.'f', $arg; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 11 | my ($seconds, $microseconds) = split /\./, $arg; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 11 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | ▶ | my @lt = $gm ? CORE::gmtime($arg) : CORE::localtime($arg); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | 7 | ▶ | $lt[0] .= ".$microseconds" if $PRECISION; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | $lt[5] += 1900; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 7 | return @lt; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | ▶ | my $str = $gm ? scalar CORE::gmtime($arg) : scalar CORE::localtime($arg); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | ▶ | $str = 0 unless defined $str; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | ▶ | $str =~ s/(\d{2}:\d{2}:\d{2}) (\d{4})/$PRECISION ? "$1.$microseconds $2" : "$1 $2"/e; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 4 | $str; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | ▶ | sub localtime (;$) { # Precise localtime: always use full year format. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
localtime: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | unshift @_, 0; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | goto &_localtime; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 10 | ▶ | sub gmtime (;$) { # Precise localtime: always use full year format. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gmtime: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 10 | unshift @_, 1; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 10 | goto &_localtime; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | sub sleep { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sleep: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | my $t = shift; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | Time::HiRes::sleep($t); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | ▶ | sub _daygm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_daygm: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | # This is written in such a byzantine way in order to avoid | ||||||||||||||||||||||||||||||||||||||||||
| 131 | # lexical variables and sub calls, for speed | ||||||||||||||||||||||||||||||||||||||||||
| 132 | return $_[3] + ( | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | ▶ | $Cheat{ pack( 'ss', @_[ 4, 5 ] ) } ||= do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$Cheat{pack "ss", @_[4, 5]} ||= do {
my $month = ($_[4] + 10) % 12;
my $year = $_[5] - int($month / 10);
365 * $year + int($year / 4) - int($year / 100) + int($year / 400) + int(($month * 306 + 5) / 10) - $Epoc
}
MC/DC0%0/2
$Cheat{pack "ss", @_[4, 5]} ||= do {
my $month = ($_[4] + 10) % 12;
my $year = $_[5] - int($month / 10);
365 * $year + int($year / 4) - int($year / 100) + int($year / 400) + int(($month * 306 + 5) / 10) - $Epoc
}
$Cheat{pack "ss", @_[4, 5]}
do {
my $month = ($_[4] + 10) % 12;
my $year = $_[5] - int($month / 10);
365 * $year + int($year / 4) - int($year / 100) + int($year / 400) + int(($month * 306 + 5) / 10) - $Epoc
}
Truth table66%2/3
A ||= B
A= $Cheat{pack "ss", @_[4, 5]}B= do {
my $month = ($_[4] + 10) % 12;
my $year = $_[5] - int($month / 10);
365 * $year + int($year / 4) - int($year / 100) + int($year / 400) + int(($month * 306 + 5) / 10) - $Epoc
}
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 3 | my $month = ( $_[4] + 10 ) % 12; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | my $year = $_[5] - int($month / 10); | |||||||||||||||||||||||||||||||||||||||||
| 136 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | ( 365 * $year ) | |||||||||||||||||||||||||||||||||||||||||
| 138 | + int( $year / 4 ) | ||||||||||||||||||||||||||||||||||||||||||
| 139 | - int( $year / 100 ) | ||||||||||||||||||||||||||||||||||||||||||
| 140 | + int( $year / 400 ) | ||||||||||||||||||||||||||||||||||||||||||
| 141 | + int( ( ( $month * 306 ) + 5 ) / 10 ) | ||||||||||||||||||||||||||||||||||||||||||
| 142 | ) - $Epoc; | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | sub _timegm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_timegm: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $sec = | |||||||||||||||||||||||||||||||||||||||||
| 149 | $SecOff + $_[0] + ( SECS_PER_MINUTE * $_[1] ) + ( SECS_PER_HOUR * $_[2] ); | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | return $sec + ( SECS_PER_DAY * &_daygm ); | |||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | ▶ | sub timegm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timegm: called CC=19 SCAR=41.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | my ( $sec, $min, $hour, $mday, $month, $year ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | ($sec, my $microsec) = split /\./, sprintf '%.'.$PRECISION.'f', $sec; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | ▶ | unless ( $Options{no_range_check} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | croak "Month '$month' out of range 0..11" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$month > 11 or $month < 0
MC/DC0%0/2
$month > 11 or $month < 0
$month > 11
$month < 0
Truth table33%1/3
A or B
A= $month > 11B= $month < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | if $month > 11 | ||||||||||||||||||||||||||||||||||||||||||
| 160 | or $month < 0; | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | my $md = $MonthDays[$month]; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | ++$md | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$month == 1 and _is_leap_year($year)
MC/DC0%0/2
$month == 1 and _is_leap_year($year)
$month == 1
_is_leap_year($year)
Truth table33%1/3
A and B
A= $month == 1B= _is_leap_year($year)
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | if $month == 1 && _is_leap_year( $year ); | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | ▶ | croak "Day '$mday' out of range 1..$md" if $mday > $md or $mday < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$mday > $md or $mday < 1
MC/DC0%0/2
$mday > $md or $mday < 1
$mday > $md
$mday < 1
Truth table33%1/3
A or B
A= $mday > $mdB= $mday < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | ▶ | croak "Hour '$hour' out of range 0..23" if $hour > 23 or $hour < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$hour > 23 or $hour < 0
MC/DC0%0/2
$hour > 23 or $hour < 0
$hour > 23
$hour < 0
Truth table33%1/3
A or B
A= $hour > 23B= $hour < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | ▶ | croak "Minute '$min' out of range 0..59" if $min > 59 or $min < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$min > 59 or $min < 0
MC/DC0%0/2
$min > 59 or $min < 0
$min > 59
$min < 0
Truth table33%1/3
A or B
A= $min > 59B= $min < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | croak "Second '$sec' out of range 0..59" if $sec > 59 or $sec < 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$sec > 59 or $sec < 0
MC/DC0%0/2
$sec > 59 or $sec < 0
$sec > 59
$sec < 0
Truth table33%1/3
A or B
A= $sec > 59B= $sec < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | my $days = _daygm( undef, undef, undef, $mday, $month, $year ); | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | ▶ | unless ($Options{no_range_check} or abs($days) < $MaxDay) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Options{"no_range_check"} or abs $days < $MaxDay
MC/DC0%0/2
$Options{"no_range_check"} or abs $days < $MaxDay
$Options{"no_range_check"}
abs $days < $MaxDay
Truth table33%1/3
A or B
A= $Options{"no_range_check"}B= abs $days < $MaxDay
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my $msg = ''; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | $msg .= "Day too big - $days > $MaxDay\n" if $days > $MaxDay; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $msg .= "Cannot handle date ($sec, $min, $hour, $mday, $month, $year)"; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | croak $msg; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | my $fix = 0; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | $fix -= 60*60*24 if ($year < 0 and not _is_leap_year($year)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$year < 0 and not _is_leap_year($year)
MC/DC0%0/2
$year < 0 and not _is_leap_year($year)
$year < 0
not _is_leap_year($year)
Truth table33%1/3
A and not(B)
A= $year < 0B= not _is_leap_year($year)
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | return ($sec | |||||||||||||||||||||||||||||||||||||||||
| 186 | + $SecOff | ||||||||||||||||||||||||||||||||||||||||||
| 187 | + ( SECS_PER_MINUTE * $min ) | ||||||||||||||||||||||||||||||||||||||||||
| 188 | + ( SECS_PER_HOUR * $hour ) | ||||||||||||||||||||||||||||||||||||||||||
| 189 | + ( SECS_PER_DAY * $days ) | ||||||||||||||||||||||||||||||||||||||||||
| 190 | + $fix).".$microsec"; | ||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 6 | ▶ | sub _is_leap_year { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_leap_year: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 6 | ▶ | return 0 if $_[0] % 4; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | return 1 if $_[0] % 100; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | return 0 if $_[0] % 400; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub timegm_nocheck { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timegm_nocheck: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | local $Options{no_range_check} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return &timegm; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub timelocal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timelocal: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my ($ref_t, $microsec) = split /\./, &timegm; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $ref_t += 60*60*24 if ($_[5] < 0 and not _is_leap_year($_[5])); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_[5] < 0 and not _is_leap_year($_[5])
MC/DC0%0/2
$_[5] < 0 and not _is_leap_year($_[5])
$_[5] < 0
not _is_leap_year($_[5])
Truth table0%0/3
A and not(B)
A= $_[5] < 0B= not _is_leap_year($_[5])
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $loc_for_ref_t = _timegm( localtime($ref_t) ); | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | my $zone_off = $loc_for_ref_t - $ref_t | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | or return "$loc_for_ref_t.$microsec"; | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | # Adjust for timezone | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my $loc_t = $ref_t - $zone_off; | |||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | # Are we close to a DST change or are we done | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $dst_off = $ref_t - _timegm( localtime($loc_t) ); | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | # If this evaluates to true, it means that the value in $loc_t is | ||||||||||||||||||||||||||||||||||||||||||
| 220 | # the _second_ hour after a DST change where the local time moves | ||||||||||||||||||||||||||||||||||||||||||
| 221 | # backward. | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if ( ! $dst_off && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $dst_off and $ref_t - 3600 - _timegm(&Time::Precise::localtime($loc_t - 3600)) < 0
MC/DC0%0/2
not $dst_off and $ref_t - 3600 - _timegm(&Time::Precise::localtime($loc_t - 3600)) < 0
not $dst_off
$ref_t - 3600 - _timegm(&Time::Precise::localtime($loc_t - 3600)) < 0
Truth table0%0/3
not(A) and B
A= not $dst_offB= $ref_t - 3600 - _timegm(&Time::Precise::localtime($loc_t - 3600)) < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | ( ( $ref_t - SECS_PER_HOUR ) - _timegm( localtime( $loc_t - SECS_PER_HOUR ) ) < 0 ) | ||||||||||||||||||||||||||||||||||||||||||
| 224 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return ''.($loc_t - SECS_PER_HOUR).".$microsec"; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | # Adjust for DST change | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $loc_t += $dst_off; | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | return "$loc_t.$microsec" if $dst_off > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | # If the original date was a non-extent gap in a forward DST jump, | ||||||||||||||||||||||||||||||||||||||||||
| 234 | # we should now have the wrong answer - undo the DST adjustment | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my ( $s, $m, $h ) = localtime($loc_t); | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | $loc_t -= $dst_off if $s != $_[0] || $m != $_[1] || $h != $_[2]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$s != $_[0] or $m != $_[1] or $h != $_[2]
$s != $_[0] or $m != $_[1]
MC/DC0%0/3
$s != $_[0] or $m != $_[1] or $h != $_[2]
$s != $_[0]
$m != $_[1]
$h != $_[2]
Truth table0%0/4
A or B or C
A= $s != $_[0]B= $m != $_[1]C= $h != $_[2]
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return "$loc_t.$microsec"; | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub timelocal_nocheck { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timelocal_nocheck: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | local $Options{no_range_check} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | return &timelocal; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 6 | ▶ | sub is_valid_date { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_valid_date: called CC=13 SCAR=28.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 6 | my ($year, $month, $day) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 6 | ▶ | return 0 unless ($year =~ /^\d+$/ and $month =~ /^\d+$/ and $day =~ /^\d+$/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$year =~ /^\d+$/ and $month =~ /^\d+$/ and $day =~ /^\d+$/
$year =~ /^\d+$/ and $month =~ /^\d+$/
MC/DC0%0/3
$year =~ /^\d+$/ and $month =~ /^\d+$/ and $day =~ /^\d+$/
$year =~ /^\d+$/
$month =~ /^\d+$/
$day =~ /^\d+$/
Truth table25%1/4
A and B and C
A= $year =~ /^\d+$/B= $month =~ /^\d+$/C= $day =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 6 | $year += 0; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 6 | $month += 0; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 6 | $day += 0; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 6 | ▶ | return 0 unless $year; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | ▶ | return 0 if ($month < 1 or $month > 12); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$month < 1 or $month > 12
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
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 6 | ▶ | return 0 if $day < 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 6 | ▶ | if ($month == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | ▶ | if (is_leap_year($year)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | return 0 if $day > 29; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | return 0 if $day > 28; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | ▶ | return 0 if $day > $month_duration->{$month}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 6 | ▶ | sub is_leap_year { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_leap_year: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 6 | _is_leap_year(shift); | |||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub time_hashref (;$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time_hashref: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | _time_hashref(shift); | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | ▶ | sub gmtime_hashref (;$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gmtime_hashref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 2 | _time_hashref(shift, 1); | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | ▶ | sub localtime_ts (;$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
localtime_ts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | my $t = _time_hashref(shift); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | "$t->{year}-$t->{month}-$t->{day} $t->{hour}:$t->{minute}:$t->{second}"; | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | ▶ | sub gmtime_ts (;$) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gmtime_ts: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 1 | my $t = _time_hashref(shift, 1); | |||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | "$t->{year}-$t->{month}-$t->{day} $t->{hour}:$t->{minute}:$t->{second}"; | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | ▶ | sub _time_hashref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_time_hashref: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | my $time = shift; | |||||||||||||||||||||||||||||||||||||||||
| 291 | 4 | my $gmt = shift; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 4 | ▶ | $time = time() unless defined $time; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 4 | ▶ | my @lt = $gmt ? gmtime(int $time) : localtime(int $time); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 4 | (my $microseconds = sprintf '%0.'.$PRECISION.'f', ($time - int $time)) =~ s/^.+\.//; | |||||||||||||||||||||||||||||||||||||||||
| 295 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 4 | ▶ | second => ($PRECISION ? sprintf("%02d.$microseconds", $lt[0]) : $lt[0]), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | minute => sprintf("%02d", $lt[1]), | ||||||||||||||||||||||||||||||||||||||||||
| 298 | hour => sprintf("%02d", $lt[2]), | ||||||||||||||||||||||||||||||||||||||||||
| 299 | day => sprintf("%02d", $lt[3]), | ||||||||||||||||||||||||||||||||||||||||||
| 300 | month => sprintf("%02d", ($lt[4] + 1)), | ||||||||||||||||||||||||||||||||||||||||||
| 301 | year => sprintf("%04d", $lt[5]), | ||||||||||||||||||||||||||||||||||||||||||
| 302 | wday => $lt[6], | ||||||||||||||||||||||||||||||||||||||||||
| 303 | yday => $lt[7], | ||||||||||||||||||||||||||||||||||||||||||
| 304 | isdst => $lt[8], | ||||||||||||||||||||||||||||||||||||||||||
| 305 | is_leap_year => is_leap_year($lt[5]), | ||||||||||||||||||||||||||||||||||||||||||
| 306 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub get_time_from { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_time_from: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | _get_time_from('', @_); | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | sub get_gmtime_from { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_gmtime_from: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | _get_time_from(1, @_); | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 1 | ▶ | sub _get_time_from { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_time_from: called CC=15 SCAR=33.8
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 1 | my @call = caller; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | my $gm = shift; | |||||||||||||||||||||||||||||||||||||||||
| 320 | 1 | ▶ | die("get_time_from expects name => value optional parameters (day, month, year, hour, minute, second) at $call[1] line $call[2]\n") if @_ % 2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | ▶ | my $time = $gm ? gmtime_hashref : time_hashref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | my $p = { | ||||||||||||||||||||||||||||||||||||||||||
| 323 | day => $time->{day}, | ||||||||||||||||||||||||||||||||||||||||||
| 324 | month => $time->{month}, | ||||||||||||||||||||||||||||||||||||||||||
| 325 | year => $time->{year}, | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | minute => 0, | |||||||||||||||||||||||||||||||||||||||||
| 327 | hour => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 328 | second => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 329 | @_, | ||||||||||||||||||||||||||||||||||||||||||
| 330 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | for my $i (qw(day month year minute hour second)) { | |||||||||||||||||||||||||||||||||||||||||
| 332 | 6 | ▶ | die("Parameter $i must be numeric at $call[1] line $call[2]\n") unless $p->{$i} =~ /^(-){0,1}\d+(\.\d+){0,1}$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 1 | ▶ | die("Invalid parameter month, out of range 1..12 at $call[1] line $call[2]\n") if ($p->{month} < 1 or $p->{month} > 12); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$p->{"month"} < 1 or $p->{"month"} > 12
MC/DC0%0/2
$p->{"month"} < 1 or $p->{"month"} > 12
$p->{"month"} < 1
$p->{"month"} > 12
Truth table33%1/3
A or B
A= $p->{"month"} < 1B= $p->{"month"} > 12
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | for my $i (qw(minute hour second)) { | |||||||||||||||||||||||||||||||||||||||||
| 336 | 3 | ▶ | die("Invalid parameter $i, out of range '>= 0' and '< 60' at $call[1] line $call[2]\n") unless $p->{$i} >= 0 and $p->{$i} < 60; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$p->{$i} >= 0 and $p->{$i} < 60
MC/DC0%0/2
$p->{$i} >= 0 and $p->{$i} < 60
$p->{$i} >= 0
$p->{$i} < 60
Truth table33%1/3
A and B
A= $p->{$i} >= 0B= $p->{$i} < 60
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | ▶ | my $max_day = $month_duration->{int $p->{month}} + ((int($p->{month}) == 2) ? is_leap_year($p->{year}) ? 1 : 0 : 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | ▶ | die("Invalid parameter day, out of range 1-$max_day at $call[1] line $call[2]\n") unless $p->{day} >= 1 and $p->{day} <= $max_day; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$p->{"day"} >= 1 and $p->{"day"} <= $max_day
MC/DC0%0/2
$p->{"day"} >= 1 and $p->{"day"} <= $max_day
$p->{"day"} >= 1
$p->{"day"} <= $max_day
Truth table33%1/3
A and B
A= $p->{"day"} >= 1B= $p->{"day"} <= $max_day
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 1 | ▶ | $gm ? timegm($p->{second}, $p->{minute}, $p->{hour}, $p->{day}, $p->{month}-1, $p->{year}) : timelocal($p->{second}, $p->{minute}, $p->{hour}, $p->{day}, $p->{month}-1, $p->{year}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | __END__ | ||||||||||||||||||||||||||||||||||||||||||