| 1 | package Date::TimeOfDay; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.010001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use overload ( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | #fallback => 1, | ||||||||||||||||||||||||||||
| 9 | '<=>' => '_compare_overload', | ||||||||||||||||||||||||||||
| 10 | 'cmp' => '_string_compare_overload', | ||||||||||||||||||||||||||||
| 11 | q{""} => 'stringify', | ||||||||||||||||||||||||||||
| 12 | q{0+} => 'float', | ||||||||||||||||||||||||||||
| 13 | 2 | ▶ | bool => sub {1}, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | #'-' => '_subtract_overload', | ||||||||||||||||||||||||||||
| 15 | #'+' => '_add_overload', | ||||||||||||||||||||||||||||
| 16 | 2 | 'eq' => '_string_equals_overload', | |||||||||||||||||||||||||||
| 17 | 'ne' => '_string_not_equals_overload', | ||||||||||||||||||||||||||||
| 18 | 2 | ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 2 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||
| 21 | 2 | our $DATE = '2022-09-22'; # DATE | |||||||||||||||||||||||||||
| 22 | 2 | our $DIST = 'Date-TimeOfDay'; # DIST | |||||||||||||||||||||||||||
| 23 | 2 | our $VERSION = '0.006'; # VERSION | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=18 SCAR=33.1
Pod
documented
| |||||||||||||||||||||||||||||
| 26 | 8 | my $class = shift; | |||||||||||||||||||||||||||
| 27 | 8 | my %args = @_; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 8 | my $tod = 0; | |||||||||||||||||||||||||||
| 30 | 8 | ▶ | if (defined $args{hour}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | die "'hour' must be an integer" | ||||||||||||||||||||||||||||
| 32 | 7 | ▶ | unless $args{hour} == int($args{hour}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | die "'hour' must be between 0 & 23" | ||||||||||||||||||||||||||||
| 34 | 7 | ▶ | unless $args{hour} >= 0 && $args{hour} <= 23; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args{"hour"} >= 0 and $args{"hour"} <= 23
MC/DC50%1/2
$args{"hour"} >= 0 and $args{"hour"} <= 23
$args{"hour"} >= 0
$args{"hour"} <= 23
Truth table66%2/3
A and B
A= $args{"hour"} >= 0B= $args{"hour"} <= 23
| |||||||||||||||||||||||||||||
| 35 | 6 | $tod += delete($args{hour}) * 3600; | |||||||||||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||||||||||
| 37 | 1 | die "Please specify 'hour'"; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 6 | ▶ | if (defined $args{minute}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | die "'minute' must be an integer" | ||||||||||||||||||||||||||||
| 41 | 6 | ▶ | unless $args{minute} == int($args{minute}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | die "'minute' must be between 0 & 59" | ||||||||||||||||||||||||||||
| 43 | 6 | ▶ | unless $args{minute} >= 0 && $args{minute} <= 59; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"minute"} >= 0 and $args{"minute"} <= 59
MC/DC0%0/2
$args{"minute"} >= 0 and $args{"minute"} <= 59
$args{"minute"} >= 0
$args{"minute"} <= 59
Truth table33%1/3
A and B
A= $args{"minute"} >= 0B= $args{"minute"} <= 59
| |||||||||||||||||||||||||||||
| 44 | 6 | $tod += delete($args{minute}) * 60; | |||||||||||||||||||||||||||
| 45 | } else { | ||||||||||||||||||||||||||||
| 46 | 0 | die "Please specify 'minute'"; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 6 | ▶ | if (defined $args{second}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | die "'second' must be an integer" | ||||||||||||||||||||||||||||
| 50 | 6 | ▶ | unless $args{second} == int($args{second}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | die "'second' must be between 0 & 59" | ||||||||||||||||||||||||||||
| 52 | 6 | ▶ | unless $args{second} >= 0 && $args{second} <= 59; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"second"} >= 0 and $args{"second"} <= 59
MC/DC0%0/2
$args{"second"} >= 0 and $args{"second"} <= 59
$args{"second"} >= 0
$args{"second"} <= 59
Truth table33%1/3
A and B
A= $args{"second"} >= 0B= $args{"second"} <= 59
| |||||||||||||||||||||||||||||
| 53 | 6 | $tod += delete($args{second}); | |||||||||||||||||||||||||||
| 54 | } else { | ||||||||||||||||||||||||||||
| 55 | 0 | die "Please specify 'second'"; | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 6 | ▶ | if (defined $args{nanosecond}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | die "'nanosecond' must be an integer" | ||||||||||||||||||||||||||||
| 60 | 6 | ▶ | unless $args{nanosecond} == int($args{nanosecond}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | die "'nanosecond' must be between 0 & 999_999_999" | ||||||||||||||||||||||||||||
| 62 | 6 | ▶ | unless $args{nanosecond} >= 0 && $args{nanosecond} <= 999_999_999; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$args{"nanosecond"} >= 0 and $args{"nanosecond"} <= 999999999
MC/DC0%0/2
$args{"nanosecond"} >= 0 and $args{"nanosecond"} <= 999999999
$args{"nanosecond"} >= 0
$args{"nanosecond"} <= 999999999
Truth table33%1/3
A and B
A= $args{"nanosecond"} >= 0B= $args{"nanosecond"} <= 999999999
| |||||||||||||||||||||||||||||
| 63 | 6 | $tod += delete($args{nanosecond}) / 1e9; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 6 | ▶ | die "Unknown parameter(s): ".join(", ", sort keys %args) if keys %args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 5 | return bless \$tod, $class; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 10 | ▶ | sub from_float { | ||||||||||||||||||||||||||
|
Subroutine
from_float: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 10 | my $class = shift; | |||||||||||||||||||||||||||
| 73 | 10 | my %args = @_; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 10 | my $tod; | |||||||||||||||||||||||||||
| 76 | 10 | ▶ | if (defined $args{float}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 9 | $tod = delete($args{float}) + 0; | |||||||||||||||||||||||||||
| 78 | 9 | ▶ | die "'float' must be between 0-86400" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$tod >= 0 and $tod < 86400
MC/DC100%2/2
$tod >= 0 and $tod < 86400
$tod >= 0
$tod < 86400
Truth table100%3/3
A and B
A= $tod >= 0B= $tod < 86400
| |||||||||||||||||||||||||||||
| 79 | unless $tod >= 0 && $tod < 86400; | ||||||||||||||||||||||||||||
| 80 | } else { | ||||||||||||||||||||||||||||
| 81 | 1 | die "Please specify 'float'"; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 7 | ▶ | die "Unknown parameter(s): ".join(", ", sort keys %args) if keys %args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 6 | return bless \$tod, $class; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 4 | ▶ | sub from_hms { | ||||||||||||||||||||||||||
|
Subroutine
from_hms: called CC=6 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 91 | 4 | my %args = @_; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 4 | my $tod; | |||||||||||||||||||||||||||
| 94 | 4 | ▶ | if (defined $args{hms}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 4 | my $hms = delete $args{hms}; | |||||||||||||||||||||||||||
| 96 | 4 | ▶ | $hms =~ /\A([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2})(\.[0-9]{1,9})?)?\z/ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | or die "Invalid hms '$hms', must be hh:mm:ss or hh:mm"; | ||||||||||||||||||||||||||||
| 98 | 4 | ▶ | $tod = $class->new( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 99 | hour=>$1, minute=>$2, | ||||||||||||||||||||||||||||
| 100 | second => defined($3) ? $3 : 0, | ||||||||||||||||||||||||||||
| 101 | nanosecond=>defined($4) ? $4*1e9 : 0); | ||||||||||||||||||||||||||||
| 102 | } else { | ||||||||||||||||||||||||||||
| 103 | 0 | die "Please specify 'hms'"; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 4 | ▶ | die "Unknown parameter(s): ".join(", ", sort keys %args) if keys %args; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 4 | $tod; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 4 | ▶ | sub _now { | ||||||||||||||||||||||||||
|
Subroutine
_now: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 112 | 4 | require Time::Local; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 4 | my ($class, $utc, $time) = @_; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 4 | ▶ | my @time = $utc ? gmtime($time) : localtime($time); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 4 | @time[0..2] = (0,0,0); | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 4 | ▶ | my $time_bod = $utc ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | Time::Local::timegm(@time) : Time::Local::timelocal(@time); | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 4 | my $tod = $time - $time_bod; | |||||||||||||||||||||||||||
| 123 | 4 | return bless \$tod, $class; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 1 | ▶ | sub now_local { | ||||||||||||||||||||||||||
|
Subroutine
now_local: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 127 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 128 | 1 | $class->_now(0, time()); | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 1 | ▶ | sub now_utc { | ||||||||||||||||||||||||||
|
Subroutine
now_utc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 132 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 133 | 1 | $class->_now(1, time()); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 1 | ▶ | sub hires_now_local { | ||||||||||||||||||||||||||
|
Subroutine
hires_now_local: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 137 | 1 | require Time::HiRes; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 140 | 1 | $class->_now(0, Time::HiRes::time()); | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 1 | ▶ | sub hires_now_utc { | ||||||||||||||||||||||||||
|
Subroutine
hires_now_utc: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 144 | 1 | require Time::HiRes; | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 147 | 1 | $class->_now(1, Time::HiRes::time()); | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 27 | ▶ | sub _elements { | ||||||||||||||||||||||||||
|
Subroutine
_elements: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 151 | 27 | my $self = shift; | |||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 27 | my $n = $$self; | |||||||||||||||||||||||||||
| 154 | 27 | my $hour = int($n / 3600); $n -= $hour*3600; | |||||||||||||||||||||||||||
| 155 | 27 | my $minute = int($n / 60); $n -= $minute*60; | |||||||||||||||||||||||||||
| 156 | 27 | my $second = int($n); $n -= $second; | |||||||||||||||||||||||||||
| 157 | 27 | my $nanosecond = sprintf("%.0f", $n*1e9); | |||||||||||||||||||||||||||
| 158 | 27 | ($hour, $minute, $second, $nanosecond); | |||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 1 | ▶ | sub hour { | ||||||||||||||||||||||||||
|
Subroutine
hour: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 162 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 1 | my ($hour, $minute, $second, $nanosecond) = $self->_elements; | |||||||||||||||||||||||||||
| 165 | 1 | $hour; | |||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 1 | ▶ | sub minute { | ||||||||||||||||||||||||||
|
Subroutine
minute: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 169 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 1 | my ($hour, $minute, $second, $nanosecond) = $self->_elements; | |||||||||||||||||||||||||||
| 172 | 1 | $minute; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 1 | ▶ | sub second { | ||||||||||||||||||||||||||
|
Subroutine
second: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 1 | my ($hour, $minute, $second, $nanosecond) = $self->_elements; | |||||||||||||||||||||||||||
| 179 | 1 | $second; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 2 | ▶ | sub nanosecond { | ||||||||||||||||||||||||||
|
Subroutine
nanosecond: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 183 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 2 | my ($hour, $minute, $second, $nanosecond) = $self->_elements; | |||||||||||||||||||||||||||
| 186 | 2 | $nanosecond; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 11 | ▶ | sub float { | ||||||||||||||||||||||||||
|
Subroutine
float: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 190 | 11 | my $self = shift; | |||||||||||||||||||||||||||
| 191 | 11 | $$self; | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 6 | ▶ | sub hms { | ||||||||||||||||||||||||||
|
Subroutine
hms: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | 6 | my ($self, $sep) = @_; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 6 | ▶ | $sep //= ":"; | ||||||||||||||||||||||||||
|
Condition100%2/2
$sep //= ":"
MC/DC100%1/1
$sep //= ":"
$sep
Truth table100%2/2
A
A= $sep
| |||||||||||||||||||||||||||||
| 198 | 6 | my ($hour, $minute, $second, $nanosecond) = $self->_elements; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 6 | sprintf("%02d%s%02d%s%02d", $hour, $sep, $minute, $sep, $second); | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 16 | ▶ | sub stringify { | ||||||||||||||||||||||||||
|
Subroutine
stringify: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 204 | 16 | my $self = shift; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 16 | my ($hour, $minute, $second, $nanosecond) = $self->_elements; | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 16 | ▶ | if ($nanosecond) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 1 | ▶ | sprintf( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 210 | "%02d:%02d:%s%.11g", | ||||||||||||||||||||||||||||
| 211 | $hour, | ||||||||||||||||||||||||||||
| 212 | $minute, | ||||||||||||||||||||||||||||
| 213 | $second < 10 ? "0" : "", | ||||||||||||||||||||||||||||
| 214 | $second + $nanosecond/1e9); | ||||||||||||||||||||||||||||
| 215 | } else { | ||||||||||||||||||||||||||||
| 216 | 15 | sprintf("%02d:%02d:%02d", $hour, $minute, $second); | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub strftime { | ||||||||||||||||||||||||||
|
Subroutine
strftime: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 221 | # XXX | ||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 5 | ▶ | sub compare { | ||||||||||||||||||||||||||
|
Subroutine
compare: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||
| 225 | 5 | ▶ | my $class = ref $_[0] ? undef : shift; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 5 | my ($tod1, $tod2) = @_; | |||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 5 | ▶ | unless ($tod1->can('float') && $tod2->can('float')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$tod1->can("float") and $tod2->can("float")
MC/DC0%0/2
$tod1->can("float") and $tod2->can("float")
$tod1->can("float")
$tod2->can("float")
Truth table33%1/3
A and B
A= $tod1->can("float")B= $tod2->can("float")
| |||||||||||||||||||||||||||||
| 229 | 0 | die "A Date::TimeOfDay object can only be compared to another ". | |||||||||||||||||||||||||||
| 230 | "Date::TimeOfDay object"; | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | 5 | $tod1->float <=> $tod2->float; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 1 | ▶ | sub _compare_overload { | ||||||||||||||||||||||||||
|
Subroutine
_compare_overload: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 236 | 1 | my ($tod1, $tod2, $flip) = @_; | |||||||||||||||||||||||||||
| 237 | 1 | ▶ | ($flip ? -1:1) * (compare($tod1, $tod2)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 3 | ▶ | sub _string_compare_overload { | ||||||||||||||||||||||||||
|
Subroutine
_string_compare_overload: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||
| 241 | 3 | my ($tod1, $tod2, $flip) = @_; | |||||||||||||||||||||||||||
| 242 | 3 | ▶ | ($flip ? -1:1) * ("$tod1" cmp "$tod2"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 2 | ▶ | sub _string_equals_overload { | ||||||||||||||||||||||||||
|
Subroutine
_string_equals_overload: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 246 | 2 | my ($tod1, $tod2) = @_; | |||||||||||||||||||||||||||
| 247 | 2 | "$tod1" eq "$tod2"; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 2 | ▶ | sub _string_not_equals_overload { | ||||||||||||||||||||||||||
|
Subroutine
_string_not_equals_overload: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 251 | 2 | my ($tod1, $tod2) = @_; | |||||||||||||||||||||||||||
| 252 | 2 | "$tod1" ne "$tod2"; | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 2 | 1; | |||||||||||||||||||||||||||
| 256 | # ABSTRACT: Represent time of day (hh:mm:ss) | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | __END__ | ||||||||||||||||||||||||||||