| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Module Generic - ~/lib/Module/Generic/DateTime.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.6.5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2026 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2021/03/20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2026/06/04 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | package Module::Generic::DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use v5.16.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | warnings::register_categories( 'Module::Generic' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use vars qw( $ERROR $TS_RE $VERSION $NUMBER_REAL_RE $NUMBER_INT_RE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | use DateTime::Lite v0.6.3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use DateTime::Format::Lite v0.1.2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | ▶ | use DateTime::Lite::TimeZone v0.5.3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | ▶ | use Module::Generic::Global ':const'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 26 | ▶ | q{""} => sub{ ( $_[0]->{dt} && Scalar::Util::blessed( $_[0]->{dt} ) ) ? $_[0]->{dt}->stringify : '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=14.2
Branch: 1 branch
Condition33%1/3
$_[0]{"dt"} and builtin::blessed($_[0]{"dt"})
MC/DC0%0/2
$_[0]{"dt"} and builtin::blessed($_[0]{"dt"})
$_[0]{"dt"}
builtin::blessed($_[0]{"dt"})
Truth table33%1/3
A and B
A= $_[0]{"dt"}B= builtin::blessed($_[0]{"dt"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 15 | ▶ | bool => sub{1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | ▶ | q{>} => sub{ &op( @_, '>' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | q{>=} => sub{ &op( @_, '>=' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | q{<} => sub{ &op( @_, '<' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | q{<=} => sub{ &op( @_, '<=' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | q{==} => sub{ &op( @_, '==' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | q{!=} => sub{ &op( @_, '!=' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | q{-} => sub{ &op_minus_plus( @_, '-' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | q{+} => sub{ &op_minus_plus( @_, '+' ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 5 | fallback => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 5 | $TS_RE = qr/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | (?<year>\d{4}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | (?<month>\d{1,2}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | (?<day>\d{1,2}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | ([[:blank:]]+|T) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | (?<hour>\d{1,2}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | \: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | (?<minute>\d{1,2}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | \: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | (?<second>\d{1,2}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | (?<tz_offset> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | (?<tz_sign>[-+]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | (?<tz_offset1>\d{1,2})(?<tz_offset2>\d{2}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | /x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | $NUMBER_REAL_RE = qr/(?:(?i)(?:[-+]?)(?:(?=[.]?[0123456789])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[-+]?)(?:[0123456789]+))|))/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | $NUMBER_INT_RE = qr/(?:(?:[-+]?)(?:[0123456789]+))/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 5 | our $VERSION = 'v0.6.5'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 5 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 21 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=17 SCAR=37.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 21 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 21 | my $dt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # Module::Generic::DateTime->new( $datetime_object ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # Module::Generic::DateTime->new( $datetime_object, $hash_ref_of_options ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # Module::Generic::DateTime->new( $datetime_object, %hash_of_options ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # Module::Generic::DateTime->new( $datetime_object, %hash_of_options ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # Module::Generic::DateTime->new( $hash_ref_of_options ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # Module::Generic::DateTime->new( %hash_of_options ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 21 | ▶ | if( scalar( @_ ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @_ and $this->_is_a($_[0], ["DateTime", "DateTime::Lite"])
MC/DC50%1/2
scalar @_ and $this->_is_a($_[0], ["DateTime", "DateTime::Lite"])
scalar @_
$this->_is_a($_[0], ["DateTime", "DateTime::Lite"])
Truth table66%2/3
A and B
A= scalar @_B= $this->_is_a($_[0], ["DateTime", "DateTime::Lite"])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | $this->_is_a( $_[0] => [qw( DateTime DateTime::Lite )] ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 20 | $dt = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 21 | my $opts = $this->_get_args_as_hash( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 21 | ▶ | if( !defined( $dt ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | my @params = qw( year month day hour minute second nanosecond ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | my $args = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | for( @params ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 7 | ▶ | $args->{ $_ } = $opts->{ $_ } if( CORE::exists( $opts->{ $_ } ) && CORE::length( $opts->{ $_ } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $opts->{$_} and length $opts->{$_}
MC/DC0%0/2
exists $opts->{$_} and length $opts->{$_}
exists $opts->{$_}
length $opts->{$_}
Truth table33%1/3
A and B
A= exists $opts->{$_}B= length $opts->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | if( scalar( keys( %$args ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $dt = DateTime::Lite->new( %$opts ) || return( $this->pass_error( DateTime::Lite->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'DateTime::Lite'->new(%$opts) || (return $this->pass_error('DateTime::Lite'->error))
MC/DC0%0/1
'DateTime::Lite'->new(%$opts) || (return $this->pass_error('DateTime::Lite'->error))
'DateTime::Lite'->new(%$opts)
Truth table0%0/2
A
A= 'DateTime::Lite'->new(%$opts)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 1 | ▶ | unless( defined( $dt ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | if( !exists( $opts->{formatter} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | $opts->{formatter} = DateTime::Format::Lite->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'DateTime::Format::Lite'->new('pattern', '%FT%T%z', 'locale', 'en_GB') || (return $this->pass_error('DateTime::Format::Lite'->error))
MC/DC0%0/1
'DateTime::Format::Lite'->new('pattern', '%FT%T%z', 'locale', 'en_GB') || (return $this->pass_error('DateTime::Format::Lite'->error))
'DateTime::Format::Lite'->new('pattern', '%FT%T%z', 'locale', 'en_GB')
Truth table50%1/2
A
A= 'DateTime::Format::Lite'->new('pattern', '%FT%T%z', 'locale', 'en_GB')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | pattern => "%FT%T%z", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | locale => "en_GB", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | ) || return( $this->pass_error( DateTime::Format::Lite->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | $dt = DateTime::Lite->now( %$opts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | if( !defined( $dt ) && DateTime::Lite->error ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
not defined $dt and "DateTime::Lite"->error
MC/DC0%0/2
not defined $dt and "DateTime::Lite"->error
not defined $dt
"DateTime::Lite"->error
Truth table33%1/3
not(A) and B
A= not defined $dtB= "DateTime::Lite"->error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $err = DateTime::Lite->error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if( $err->message =~ /Cannot[[:blank:]\h]+determine[[:blank:]\h]+local[[:blank:]\h]+time[[:blank:]\h]+zone/i ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | warn( "Warning: Your system is missing key timezone components. Module::Generic::DateTime is reverting to UTC instead of local time zone." ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $opts->{time_zone} = 'UTC'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | $dt = DateTime::Lite->new( %$opts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $dt_fmt = DateTime::Format::Lite->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | pattern => '%FT%T%z', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | locale => 'en_GB', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $dt->set_formatter( $dt_fmt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | return( $this->error( "Error while creating a DateTime::Lite object: $err" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | elsif( !defined( $dt ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | return( $this->error( "Unknown error occurred while creating a DateTime::Lite object." ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 21 | ▶ | return( bless( { dt => $dt->clone } => ( ref( $this ) || $this ) )->init( @_ ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table66%2/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # This class does not convert to an HASH, but the TO_JSON method will convert to a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub as_hash { return( $_[0] ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub as_string { return( shift->stringify( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub datetime { return( shift->_set_get_object_without_init( 'dt' => [qw( DateTime DateTime::Lite )] ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
datetime: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | sub from_epoch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_epoch: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | my $dt = DateTime::Lite->from_epoch( @_ ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
'DateTime::Lite'->from_epoch(@_) || (return $this->error('Error trying to create a new DateTime::Lite object using new_from_epoch(): ', 'DateTime::Lite'->error))
MC/DC0%0/1
'DateTime::Lite'->from_epoch(@_) || (return $this->error('Error trying to create a new DateTime::Lite object using new_from_epoch(): ', 'DateTime::Lite'->error))
'DateTime::Lite'->from_epoch(@_)
Truth table0%0/2
A
A= 'DateTime::Lite'->from_epoch(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | return( $this->error( "Error trying to create a new DateTime::Lite object using new_from_epoch(): ", DateTime::Lite->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return( $this->new( $dt ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | sub now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
now: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | my $dt = DateTime::Lite->now( @_ ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'DateTime::Lite'->now(@_) || (return $this->error('Error trying to create a new DateTime::Lite object: ', 'DateTime::Lite'->error))
MC/DC0%0/1
'DateTime::Lite'->now(@_) || (return $this->error('Error trying to create a new DateTime::Lite object: ', 'DateTime::Lite'->error))
'DateTime::Lite'->now(@_)
Truth table50%1/2
A
A= 'DateTime::Lite'->now(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | return( $this->error( "Error trying to create a new DateTime::Lite object: ", DateTime::Lite->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | return( $this->new( $dt ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | sub op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op: called CC=24 SCAR=40.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 4 | my( $self, $other, $swap, $op ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | ▶ | no strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 4 | my $dt1 = $self->{dt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | my $dt2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # We use a simple $class as key, because it does not matter whether this is in a process or thread | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 4 | my $err_key = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 4 | my $repo = Module::Generic::Global->new( 'local_tz' => $class, key => $err_key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 4 | ▶ | if( Scalar::Util::blessed( $other ) && ( $other->isa( 'DateTime' ) || $other->isa( 'DateTime::Lite' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition16%1/6
builtin::blessed($other) and $other->isa("DateTime") || $other->isa("DateTime::Lite")
$other->isa("DateTime") or $other->isa("DateTime::Lite")
MC/DC0%0/3
builtin::blessed($other) and $other->isa("DateTime") || $other->isa("DateTime::Lite")
builtin::blessed($other)
$other->isa("DateTime")
$other->isa("DateTime::Lite")
Truth table25%1/4
A and B or C
A= builtin::blessed($other)B= $other->isa("DateTime")C= $other->isa("DateTime::Lite")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $dt2 = $other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ▶ | elsif( Scalar::Util::blessed( $other ) && ref( $other ) eq ref( $self ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
builtin::blessed($other) and ref $other eq ref $self
MC/DC0%0/2
builtin::blessed($other) and ref $other eq ref $self
builtin::blessed($other)
ref $other eq ref $self
Truth table33%1/3
A and B
A= builtin::blessed($other)B= ref $other eq ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $dt2 = $other->{dt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # Might trigger an error if this does not work with DateTime or DateTime::Lite, but that's the developer's problem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | elsif( Scalar::Util::blessed( $other ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $dt2 = $other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # Unix time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | elsif( $other =~ /^\d{10}$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | my $has_local_tz = $repo->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | ▶ | if( !defined( $has_local_tz ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | $dt2 = DateTime::Lite->from_epoch( epoch => $other, time_zone => 'local' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | $has_local_tz = defined( $dt2 ) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | $repo->set( $has_local_tz ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | if( !defined( $dt2 ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | warn( "Your system is missing key timezone components. ${class} is reverting to UTC instead of local time zone." ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $dt2 = DateTime::Lite->from_epoch( epoch => $other, time_zone => 'UTC' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | $dt2 = DateTime::Lite->from_epoch( epoch => $other, time_zone => ( $has_local_tz ? 'local' : 'UTC' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if( !defined( $dt2 ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | warn( "Error trying to set a DateTime::Lite object using ", ( $has_local_tz ? 'local' : 'UTC' ), " time zone" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $dt2 = DateTime::Lite->from_epoch( epoch => $other, time_zone => 'UTC' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | $dt2->set_formatter( $self->formatter ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | elsif( $other =~ /^$TS_RE$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | my $re = { %+ }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | my $offset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | @$hash{ qw( year month day hour minute second ) } = @$re{ qw( year month day hour minute second ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | for( keys( %$hash ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 18 | $hash->{ $_ } = int( $hash->{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | if( $re->{tz_offset1} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | $offset = 3600 * $re->{tz_offset1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | ▶ | $offset += 60 * $re->{tz_offset2} if( length( $re->{tz_offset2} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | ▶ | $offset *= -1 if( $re->{tz_sign} && $re->{tz_sign} ne '-' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$re->{"tz_sign"} and $re->{"tz_sign"} ne "-"
MC/DC0%0/2
$re->{"tz_sign"} and $re->{"tz_sign"} ne "-"
$re->{"tz_sign"}
$re->{"tz_sign"} ne "-"
Truth table33%1/3
A and B
A= $re->{"tz_sign"}B= $re->{"tz_sign"} ne "-"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | $re->{tz_offset} = $re->{tz_sign} . $re->{tz_offset1} . $re->{tz_offset2}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | $dt2 = DateTime::Lite->new( %$hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 3 | ▶ | if( $dt2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 3 | ▶ | $dt2->set_time_zone( $re->{tz_offset} ) if( length( $re->{tz_offset} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 3 | my $dt3 = $dt2->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 3 | $dt3->set_time_zone( 'UTC' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | warn( "Unable to create DateTime::Lite object from parsing '$other': ", DateTime::Lite->error, "\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 5 | ▶ | use overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | ▶ | my $eval = $swap ? "\$dt2 $op \$dt1" : "\$dt1 $op \$dt2"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # I do not want to localise $@ so it can be checked by the caller | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | my $res = eval( $eval ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 4 | return( $res ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | sub op_minus_plus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_minus_plus: called CC=42 SCAR=59.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | my( $self, $other, $swap, $op ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | my $dt1 = $self->{dt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 4 | $other = $self->_get_other( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 5 | ▶ | use overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | my $err_key = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | my $repo = Module::Generic::Global->new( 'local_tz' => $class, key => $err_key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 4 | ▶ | if( Scalar::Util::blessed( $other ) && ( $other->isa( 'DateTime::Duration' ) || $other->isa( 'DateTime::Lite::Duration' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
builtin::blessed($other) and $other->isa("DateTime::Duration") || $other->isa("DateTime::Lite::Duration")
$other->isa("DateTime::Duration") or $other->isa("DateTime::Lite::Duration")
MC/DC66%2/3
builtin::blessed($other) and $other->isa("DateTime::Duration") || $other->isa("DateTime::Lite::Duration")
builtin::blessed($other)
$other->isa("DateTime::Duration")
$other->isa("DateTime::Lite::Duration")
Truth table75%3/4
A and B or C
A= builtin::blessed($other)B= $other->isa("DateTime::Duration")C= $other->isa("DateTime::Lite::Duration")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | ## Duration [+-] DateTime/DateTime::Lite => update the datetime object in place | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | ▶ | if( $swap ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if( $op eq '-' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $dt1->subtract_duration( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $dt1->add_duration( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1 | ▶ | my $clone = !defined( $swap ) ? $dt1 : $dt1->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1 | ▶ | if( $op eq '-' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | $clone->subtract_duration( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | $clone->add_duration( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | ▶ | return( !defined( $swap ) ? $self : $self->_make_my_own( $clone ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | ▶ | elsif( Scalar::Util::blessed( $other ) && ( $other->isa( 'DateTime' ) || $other->isa( 'DateTime::Lite' ) ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
builtin::blessed($other) and $other->isa("DateTime") || $other->isa("DateTime::Lite")
$other->isa("DateTime") or $other->isa("DateTime::Lite")
MC/DC33%1/3
builtin::blessed($other) and $other->isa("DateTime") || $other->isa("DateTime::Lite")
builtin::blessed($other)
$other->isa("DateTime")
$other->isa("DateTime::Lite")
Truth table50%2/4
A and B or C
A= builtin::blessed($other)B= $other->isa("DateTime")C= $other->isa("DateTime::Lite")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | ▶ | if( $op eq '-' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # return( $swap ? $other->subtract( $dt1 ) : $dt1->subtract( $other ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | ▶ | return( $self->_make_my_own( $swap ? ( $other - $dt1 ) : ( $dt1 - $other ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | return( $self->_make_my_own( $swap ? ( $other + $dt1 ) : ( $dt1 + $other ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | my $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | ▶ | $v = "$other" if( !ref( $other ) || ( ref( $other ) && overload::Method( $other => '""' ) ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
not ref $other or ref $other and overload::Method($other, "\"\"")
ref $other and overload::Method($other, "\"\"")
MC/DC0%0/3
not ref $other or ref $other and overload::Method($other, "\"\"")
not ref $other
ref $other
overload::Method($other, "\"\"")
Truth table25%1/4
not(A) or B and C
A= not ref $otherB= ref $otherC= overload::Method($other, "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | ▶ | die( "\$other (", overload::StrVal( $other // '' ), ") is not a number, a DateTime, a DateTime::Lite, or a DateTime::Duration object!\n" ) if( !defined( $v ) || $v !~ /^(?:$NUMBER_REAL_RE|$NUMBER_INT_RE)$/ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
defined $v and $v =~ /^(?:$NUMBER_REAL_RE|$NUMBER_INT_RE)$/
$other // ""
MC/DC0%0/2
defined $v and $v =~ /^(?:$NUMBER_REAL_RE|$NUMBER_INT_RE)$/
defined $v
$v =~ /^(?:$NUMBER_REAL_RE|$NUMBER_INT_RE)$/
MC/DC0%0/1
$other // ""
$other
Truth table33%1/3
A and B
A= defined $vB= $v =~ /^(?:$NUMBER_REAL_RE|$NUMBER_INT_RE)$/
Truth table0%0/2
A
A= $other
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 2 | my $new_dt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | ▶ | if( $op eq '-' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | ▶ | if( $swap ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | my $dt_class = ref( $dt1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | $dt_class = 'DateTime::Lite' unless( $dt_class eq 'DateTime' || $dt_class eq 'DateTime::Lite' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dt_class eq "DateTime" or $dt_class eq "DateTime::Lite"
MC/DC0%0/2
$dt_class eq "DateTime" or $dt_class eq "DateTime::Lite"
$dt_class eq "DateTime"
$dt_class eq "DateTime::Lite"
Truth table0%0/3
A or B
A= $dt_class eq "DateTime"B= $dt_class eq "DateTime::Lite"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my( $clone, $ts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $clone = $dt1->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $ts = $clone->epoch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | die( "Error cloning and getting epoch value for ${dt_class} object: $@" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my $has_local_tz = $repo->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if( !defined( $has_local_tz ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $clone->set_time_zone( 'local' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $has_local_tz = $@ ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $repo->set( $has_local_tz ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $clone->set_time_zone( 'UTC' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | warn( "Your system is missing key timezone components. ${class} is reverting to UTC instead of local time zone.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $new_ts = $v - $ts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $new_dt = $dt_class->from_epoch( epoch => $new_ts, time_zone => $dt1->time_zone ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | my $strp = DateTime::Format::Lite->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | pattern => '%s', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | locale => 'en_GB', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | time_zone => $new_dt->time_zone, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | $new_dt->set_formatter( $strp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | die( "Error instantiating a new ${dt_class} object with epoch timestamp $new_ts and time zone ", $dt1->time_zone ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | ▶ | my $clone = !defined( $swap ) ? $dt1 : $dt1->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | $new_dt = $clone->subtract( seconds => $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | die( "Failed to subtract ", ( $swap ? $self : $v ), " from ", ( $swap ? $v : $self ), ": $@" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # If $swap is undefined, this is an assignment operation such as -= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | ▶ | return( $self ) if( !defined( $swap ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # + | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 1 | ▶ | if( $swap ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | $new_dt = $dt1->add( seconds => $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | ▶ | my $clone = !defined( $swap ) ? $dt1 : $dt1->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | $new_dt = $clone->add( seconds => $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | die( "Failed to add ", ( $swap ? $self : $v ), " to ", ( $swap ? $v : $self ), ": $@" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | ▶ | return( $self ) if( !defined( $swap ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | return( $self->_make_my_own( $new_dt ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | sub _get_other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_other: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 4 | my( $self, $other ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 4 | ▶ | if( Scalar::Util::blessed( $other ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 2 | ▶ | if( $other->isa( 'Module::Generic::DateTime' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 1 | $other = $other->{dt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | elsif( $other->isa( 'Module::Generic::DateTime::Interval' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $other = $other->{interval}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 4 | return( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | sub _make_my_own | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_my_own: called CC=7 SCAR=22.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 2 | my( $self, $res ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 2 | ▶ | if( Scalar::Util::blessed( $res ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
builtin::blessed($res) and $res->isa("DateTime::Lite::Duration") || $res->isa("DateTime::Duration")
$res->isa("DateTime::Lite::Duration") or $res->isa("DateTime::Duration")
MC/DC33%1/3
builtin::blessed($res) and $res->isa("DateTime::Lite::Duration") || $res->isa("DateTime::Duration")
builtin::blessed($res)
$res->isa("DateTime::Lite::Duration")
$res->isa("DateTime::Duration")
Truth table50%2/4
A and B or C
A= builtin::blessed($res)B= $res->isa("DateTime::Lite::Duration")C= $res->isa("DateTime::Duration")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | ( $res->isa( 'DateTime::Lite::Duration' ) || $res->isa( 'DateTime::Duration' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | return( Module::Generic::DateTime::Interval->new( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | ▶ | elsif( Scalar::Util::blessed( $res ) && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
builtin::blessed($res) and $res->isa("DateTime") || $res->isa("DateTime::Lite")
$res->isa("DateTime") or $res->isa("DateTime::Lite")
MC/DC0%0/3
builtin::blessed($res) and $res->isa("DateTime") || $res->isa("DateTime::Lite")
builtin::blessed($res)
$res->isa("DateTime")
$res->isa("DateTime::Lite")
Truth table25%1/4
A and B or C
A= builtin::blessed($res)B= $res->isa("DateTime")C= $res->isa("DateTime::Lite")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ( $res->isa( 'DateTime' ) || $res->isa( 'DateTime::Lite' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | return( $self->new( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | return( $res ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # NOTE: AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=12 SCAR=32.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 6 | my( $method ) = our $AUTOLOAD =~ /([^:]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 5 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 6 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 6 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 6 | ▶ | if( !ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if( DateTime::Lite->can( $method ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $rv = DateTime::Lite->$method( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | if( Scalar::Util::blessed( $rv ) && $rv->isa( 'DateTime::Lite' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($rv) and $rv->isa("DateTime::Lite")
MC/DC0%0/2
builtin::blessed($rv) and $rv->isa("DateTime::Lite")
builtin::blessed($rv)
$rv->isa("DateTime::Lite")
Truth table0%0/3
A and B
A= builtin::blessed($rv)B= $rv->isa("DateTime::Lite")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | return( $class->new( $rv ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | die( "Method ${method} unsupported by DateTime::Lite\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 6 | ▶ | die( "DateTime::Lite object is gone !\n" ) if( !ref( $self->{dt} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 5 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 6 | my $dt = $self->{dt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 6 | ▶ | my $dt_class = ref( $dt ) || 'DateTime::Lite'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
ref $dt || 'DateTime::Lite'
MC/DC0%0/1
ref $dt || 'DateTime::Lite'
ref $dt
Truth table50%1/2
A
A= ref $dt
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 6 | ▶ | $dt_class = 'DateTime::Lite' unless( $dt_class eq 'DateTime::Lite' || $dt_class eq 'DateTime' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dt_class eq "DateTime::Lite" or $dt_class eq "DateTime"
MC/DC0%0/2
$dt_class eq "DateTime::Lite" or $dt_class eq "DateTime"
$dt_class eq "DateTime::Lite"
$dt_class eq "DateTime"
Truth table33%1/3
A or B
A= $dt_class eq "DateTime::Lite"B= $dt_class eq "DateTime"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 6 | ▶ | if( $dt->can( $method ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 6 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 6 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 6 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 6 | $rv = $dt->$method( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 6 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return( $self->error( "Error trying to call ${dt_class}::$method with arguments: '", join( "', '", @_ ), "': $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 6 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | return( $self->error( "No method \"$method\" available in ${dt_class}" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # NOTE: DESTROY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # Avoid getting caught by AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | sub DESTROY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 24 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # <https://perldoc.perl.org/perlobj#Destructors> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 24 | CORE::local( $., $@, $!, $^E, $? ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 24 | ▶ | CORE::return if( Module::Generic::_in_global_destruction() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 24 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 24 | ▶ | CORE::return if( !CORE::defined( $self ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 24 | ▶ | undef( $self->{dt} ) if( defined( $self->{dt} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | # For non-object context, we need to call cleanup to ensure there is no leftover | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 24 | my $class = ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 24 | my $err_key = $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 24 | my $repo = Module::Generic::Global->new( 'local_tz' => $class, key => $err_key ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 24 | $repo->cleanup; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 24 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | sub FREEZE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FREEZE: called CC=13 SCAR=29.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 2 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 2 | ▶ | my $serialiser = CORE::shift( @_ ) // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ // ""
MC/DC0%0/1
shift @_ // ""
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 2 | my $class = CORE::ref( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 2 | ▶ | my $dt = $self->{dt} || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'dt'} || (return)
MC/DC0%0/1
$self->{'dt'} || (return)
$self->{'dt'}
Truth table50%1/2
A
A= $self->{'dt'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 2 | my $tz = $dt->time_zone->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 2 | my $fmt = $dt->formatter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # my $locale = $dt->locale->code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 2 | my $locale; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | ▶ | if( my $loc = $dt->locale ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # Typically DateTime::Locale::FromCLDR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 2 | ▶ | if( $loc->can( 'locale' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 2 | $locale = $loc->locale; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | # Typically DateTime::Locale::FromData | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | elsif( $loc->can( 'code' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $locale = $loc->code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | $locale = "$loc"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 2 | ▶ | $locale = "$locale" if( defined( $locale ) && CORE::ref( $locale ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $locale and ref $locale
MC/DC0%0/2
defined $locale and ref $locale
defined $locale
ref $locale
Truth table33%1/3
A and B
A= defined $localeB= ref $locale
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | my $hash = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | year => $dt->year, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | month => $dt->month, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | day => $dt->day, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | hour => $dt->hour, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | minute => $dt->minute, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | second => $dt->second, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | nanosecond => $dt->nanosecond, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 2 | ▶ | $hash->{time_zone} = $tz if( $tz ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 2 | ▶ | $hash->{formatter} = $fmt if( $fmt ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 2 | ▶ | $hash->{locale} = $locale if( $locale ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # Return an array reference rather than a list so this works with Sereal and CBOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # On or before Sereal version 4.023, Sereal did not support multiple values returned | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | ▶ | if( $serialiser eq 'Sereal' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 1 | require Sereal::Encoder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 1 | require version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 1 | ▶ | if( version->parse( Sereal::Encoder->VERSION ) <= version->parse( '4.023' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | CORE::return( [$class, $hash] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | # But Storable want a list with the first element being the serialised element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 2 | CORE::return( $class, $hash ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | ▶ | sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 1 | ▶ | sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | sub STORABLE_thaw_post_processing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw_post_processing: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | my $obj = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | my @keys = %$obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | my $class = ref( $obj ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 1 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 1 | @$hash{ @keys } = @$obj{ @keys }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 1 | my $self = bless( $hash => $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 1 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # NOTE: CBOR will call the THAW method with the stored classname as first argument, the constant string CBOR as second argument, and all values returned by FREEZE as remaining arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # NOTE: Storable calls it with a blessed object it created followed with $cloning and any other arguments initially provided by STORABLE_freeze | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | sub THAW | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
THAW: called CC=17 SCAR=35.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 2 | my( $self, undef, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | ▶ | my $ref = ( CORE::scalar( @args ) == 1 && CORE::ref( $args[0] ) eq 'ARRAY' ) ? CORE::shift( @args ) : \@args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar @args == 1 and ref $args[0] eq "ARRAY"
MC/DC0%0/2
scalar @args == 1 and ref $args[0] eq "ARRAY"
scalar @args == 1
ref $args[0] eq "ARRAY"
Truth table33%1/3
A and B
A= scalar @args == 1B= ref $args[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 2 | ▶ | my $class = ( CORE::defined( $ref ) && CORE::ref( $ref ) eq 'ARRAY' && CORE::scalar( @$ref ) > 1 ) ? CORE::shift( @$ref ) : ( CORE::ref( $self ) || $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition22%2/9
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref and ref $ref eq "ARRAY"
ref $self or $self
MC/DC0%0/3
defined $ref and ref $ref eq "ARRAY" and scalar @$ref > 1
defined $ref
ref $ref eq "ARRAY"
scalar @$ref > 1
MC/DC0%0/2
ref $self or $self
ref $self
$self
Truth table25%1/4
A and B and C
A= defined $refB= ref $ref eq "ARRAY"C= scalar @$ref > 1
Truth table0%0/3
A or B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 2 | ▶ | my $hash = CORE::ref( $ref ) eq 'ARRAY' ? CORE::shift( @$ref ) : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 2 | my @keys = qw( year month day hour minute second nanosecond time_zone formatter locale ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 2 | my $opts = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 2 | foreach my $prop ( @keys ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 20 | ▶ | if( exists( $hash->{ $prop } ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
exists $hash->{$prop} and defined $hash->{$prop} and length $hash->{$prop}
exists $hash->{$prop} and defined $hash->{$prop}
MC/DC33%1/3
exists $hash->{$prop} and defined $hash->{$prop} and length $hash->{$prop}
exists $hash->{$prop}
defined $hash->{$prop}
length $hash->{$prop}
Truth table50%2/4
A and B and C
A= exists $hash->{$prop}B= defined $hash->{$prop}C= length $hash->{$prop}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | defined( $hash->{ $prop } ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | length( $hash->{ $prop } ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 18 | $opts->{ $prop } = $hash->{ $prop }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | my $dt = eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 2 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 2 | require DateTime::Lite; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 2 | DateTime::Lite->new( %$opts ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 2 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | require Module::Generic; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | warn( "Error thawing the DateTime::Lite object: $@\nParameters used were: ", Module::Generic->dump( $opts ) ) if( warnings::enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | elsif( !defined( $dt ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | warn( "Error thawing the DateTime::Lite object: ", DateTime::Lite->error, "\nParameters used were: ", Module::Generic->dump( $opts ) ) if( warnings::enabled( 'Module::Generic' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 2 | my $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | # Storable pattern requires to modify the object it created rather than returning a new one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 2 | ▶ | if( CORE::ref( $self ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | $self->{dt} = $dt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 1 | $new = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | $new = CORE::bless( { dt => $dt } => $class ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 2 | CORE::return( $new ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | sub TO_JSON | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | CORE::return( '' ) if( !$self->{dt} || !Scalar::Util::blessed( $self->{dt} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"dt"} and builtin::blessed($self->{"dt"})
MC/DC0%0/2
$self->{"dt"} and builtin::blessed($self->{"dt"})
$self->{"dt"}
builtin::blessed($self->{"dt"})
Truth table0%0/3
A and B
A= $self->{"dt"}B= builtin::blessed($self->{"dt"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | CORE::return( $self->{dt}->stringify ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # NOTE: package Module::Generic::DateTime::Interval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | package Module::Generic::DateTime::Interval; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 5 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 5 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | '""' => 'as_string', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | 'bool' => sub{1}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 5 | '+' => '__add_overload', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | '-' => '__subtract_overload', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | '*' => '__multiply_overload', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | '<=>' => '__compare_overload', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 'cmp' => '__compare_overload', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | fallback => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 5 | ▶ | use DateTime::Lite; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 5 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 5 | ▶ | use Wanted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 2 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 2 | ▶ | my $dur = shift( @_ ) || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || (return)
MC/DC0%0/1
shift @_ || (return)
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 2 | ▶ | return( bless( { interval => $dur->clone } => ( ref( $this ) || $this ) )->init( @_ ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $this || $this
MC/DC0%0/2
ref $this || $this
ref $this
$this
Truth table66%2/3
A || B
A= ref $thisB= $this
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | # This class does not convert to an HASH | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | ▶ | sub as_hash { return( $_[0] ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | return( $self->{interval}->in_units( 'seconds' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | sub dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my @info = $self->{interval}->in_units( qw( years months weeks days hours minutes seconds nanoseconds ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | my $tmpl = <<EOT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | Years ... %d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | Months .. %d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | Weeks ... %d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | Days .... %d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | Hours ... %d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | Minutes . %d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | Seconds . %d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | EOT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | return( sprintf( $tmpl, @info ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 2 | ▶ | sub days : lvalue { return( shift->__set_get_unit( 'days', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
days: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | sub hours : lvalue { return( shift->__set_get_unit( 'hours', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hours: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | ▶ | sub minutes : lvalue { return( shift->__set_get_unit( 'minutes', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minutes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | sub months : lvalue { return( shift->__set_get_unit( 'months', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
months: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | ▶ | sub nanoseconds : lvalue { return( shift->__set_get_unit( 'nanoseconds', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nanoseconds: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | sub seconds : lvalue { return( shift->__set_get_unit( 'seconds', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seconds: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 2 | ▶ | sub weeks : lvalue { return( shift->__set_get_unit( 'weeks', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
weeks: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | sub years : lvalue { return( shift->__set_get_unit( 'years', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
years: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | sub __add_overload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__add_overload: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | my( $self, $other, $swap ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my $dur1 = $self->{interval}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | $other = $self->_get_other( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | if( !defined( $swap ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | $dur1 += $other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | ▶ | elsif( Scalar::Util::blessed( $other ) && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
builtin::blessed($other) and $other->isa("DateTime::Lite::Duration") || $other->isa("DateTime::Duration") || $other->isa("Module::Generic::DateTime::Interval")
$other->isa("DateTime::Lite::Duration") or $other->isa("DateTime::Duration") or $other->isa("Module::Generic::DateTime::Interval")
$other->isa("DateTime::Lite::Duration") or $other->isa("DateTime::Duration")
MC/DC0%0/4
builtin::blessed($other) and $other->isa("DateTime::Lite::Duration") || $other->isa("DateTime::Duration") || $other->isa("Module::Generic::DateTime::Interval")
builtin::blessed($other)
$other->isa("DateTime::Lite::Duration")
$other->isa("DateTime::Duration")
$other->isa("Module::Generic::DateTime::Interval")
Truth table0%0/5
A and B or C or D
A= builtin::blessed($other)B= $other->isa("DateTime::Lite::Duration")C= $other->isa("DateTime::Duration")D= $other->isa("Module::Generic::DateTime::Interval")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | ( $other->isa( 'DateTime::Lite::Duration' ) || $other->isa( 'DateTime::Duration' ) || $other->isa( 'Module::Generic::DateTime::Interval' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | $other = $other->{interval} if( $other->isa( 'Module::Generic::DateTime::Interval' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | $res = $swap ? ( $other + $dur1 ) : ( $dur1 + $other ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | return( $self->_make_my_own( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | ▶ | elsif( !ref( $other ) || overload::Method( $other => '""' ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not ref $other or overload::Method($other, "\"\"")
MC/DC0%0/2
not ref $other or overload::Method($other, "\"\"")
not ref $other
overload::Method($other, "\"\"")
Truth table0%0/3
not(A) or B
A= not ref $otherB= overload::Method($other, "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | $other = $other + 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | my $d = $dur1->in_units( 'seconds' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | my $n = $swap ? ( $other + $d ) : ( $d + $other ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $res = DateTime::Lite::Duration->new( seconds => $n ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | return( $self->_make_my_own( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | die( "Usupported data '", ref( $other ), "' in subtraction\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | sub __compare_overload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__compare_overload: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | my( $self, $other, $swap ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | my $d1 = $self->{interval}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | my $d2 = $self->_get_other( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | # my $dt = DateTime::Lite->now; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ▶ | ( $d1, $d2 ) = ( $d2, $d1 ) if( $swap ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | my $to_secs = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | if( Scalar::Util::blessed( $this ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | if( $this->isa( 'DateTime::Lite::Duration' ) || $this->isa( 'DateTime::Duration' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/3
$this->isa("DateTime::Lite::Duration") or $this->isa("DateTime::Duration")
MC/DC0%0/2
$this->isa("DateTime::Lite::Duration") or $this->isa("DateTime::Duration")
$this->isa("DateTime::Lite::Duration")
$this->isa("DateTime::Duration")
Truth table0%0/3
A or B
A= $this->isa("DateTime::Lite::Duration")B= $this->isa("DateTime::Duration")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | return( $this->in_units( 'seconds' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | ▶ | elsif( $this->isa( 'DateTime::Lite' ) || $this->isa( 'DateTime' ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$this->isa("DateTime::Lite") or $this->isa("DateTime")
MC/DC0%0/2
$this->isa("DateTime::Lite") or $this->isa("DateTime")
$this->isa("DateTime::Lite")
$this->isa("DateTime")
Truth table0%0/3
A or B
A= $this->isa("DateTime::Lite")B= $this->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | return( $this->epoch ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | elsif( $this->isa( 'Module::Generic::DateTime' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | return( $this->{dt}->epoch ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | elsif( $this->isa( 'Module::Generic::DateTime::Duration' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | return( $this->{duration}->in_units( 'seconds' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | elsif( overload::Method( $this => '""' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | return( $this + 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | die( "Unsupported object '", ref( $this ), "'\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | return( $this + 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | # return( DateTime::Lite->compare( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | # $dt->clone->add_duration( $d1 ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | # $dt->clone->add_duration( $d2 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | # ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | my $d1_secs = $to_secs->( $d1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | my $d2_secs = $to_secs->( $d2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | return( $d1_secs <=> $d2_secs ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | sub __multiply_overload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__multiply_overload: called CC=11 SCAR=35.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 2 | my( $self, $num, $swap ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 2 | my @units = qw( months days minutes seconds nanoseconds ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 2 | ▶ | if( "$num" =~ /^\d+$/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 2 | $num = int( "$num" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | ## If $swap is undefined, it means an assignment operation like *= | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 2 | ▶ | my $clone = !defined( $swap ) ? $self->{interval} : $self->{interval}->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 2 | ▶ | if( $clone->isa( 'DateTime' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $clone->multiply( $num ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 2 | $clone *= $num; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 2 | ▶ | return( !defined( $swap ) ? $self : $self->_make_my_own( $clone ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | ▶ | elsif( Scalar::Util::blessed( $num ) && $num->isa( 'Module::Generic::DateTime::Interval' ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
builtin::blessed($num) and $num->isa("Module::Generic::DateTime::Interval")
MC/DC0%0/2
builtin::blessed($num) and $num->isa("Module::Generic::DateTime::Interval")
builtin::blessed($num)
$num->isa("Module::Generic::DateTime::Interval")
Truth table0%0/3
A and B
A= builtin::blessed($num)B= $num->isa("Module::Generic::DateTime::Interval")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | ▶ | my $clone = !defined( $swap ) ? $self->{interval} : $self->{interval}->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | foreach my $t ( @units ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | $clone->{ $t } *= $num->{ $t }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | ▶ | $clone->_normalize_nanoseconds if( $clone->{nanoseconds} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | ▶ | return( !defined( $swap ) ? $self : $self->_make_my_own( $clone ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 4 | ▶ | sub __set_get_unit : lvalue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__set_get_unit: called CC=4 SCAR=17.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 4 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 4 | my $unit = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 4 | my $dur = $self->{interval}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 4 | my $coderef = $dur->can( $unit ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | my $update_value = sub | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=40.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 2 | my $v = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 2 | ▶ | if( $unit eq 'years' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | $dur->{years} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | my $p_months = $dur->{months}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | if( $p_months > 12 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | my $n_years = int( $p_months / 12 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | $p_months -= ( 12 * $n_years ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | $dur->{months} = ( $dur->{years} * 12 ) + $p_months; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | elsif( $unit eq 'months' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | $dur->{months} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | elsif( $unit eq 'weeks' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 1 | $dur->{weeks} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 1 | ▶ | if( $dur->{days} > 7 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 1 | my $p_days = $dur->{days}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 1 | my $n_weeks = int( $p_days / 7 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 1 | $p_days -= ( 7 * $n_weeks ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 1 | $dur->{days} = ( $dur->{weeks} * 7 ) + $p_days; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | elsif( $unit eq 'days' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 1 | $dur->{days} = ( $dur->{weeks} * 7 ) + $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | elsif( $unit eq 'hours' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | $dur->{hours} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | if( $dur->{minutes} > 60 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | my $p_minutes = $dur->{minutes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my $n_hours = int( $p_minutes / 60 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | $p_minutes -= ( 60 * $n_hours ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $dur->{minutes} = ( $dur->{hours} * 60 ) + $p_minutes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | elsif( $unit eq 'minutes' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | $dur->{minutes} = ( $dur->{hours} * 60 ) + $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | elsif( $unit eq 'seconds' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | $dur->{seconds} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | elsif( $unit eq 'nanoseconds' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | $dur->{nanoseconds} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | $self->_normalize_nanoseconds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 4 | ▶ | if( want( qw( LVALUE ASSIGN ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 1 | my( $v ) = want( 'ASSIGN' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 1 | $update_value->( $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 1 | $coderef->( $dur ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 1 | return( $dur->{ $unit } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 3 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 1 | my $v = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 1 | $update_value->( $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 3 | my $curr_v = $coderef->( $dur ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 3 | ▶ | return( $curr_v ) if( want( 'LVALUE' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 1 | rreturn( $curr_v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | sub __subtract_overload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__subtract_overload: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | my( $self, $other, $swap ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | my $dur1 = $self->{interval}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | $other = $self->_get_other( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 0 | my $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | ▶ | if( !defined( $swap ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 0 | $dur1 -= $other; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | ▶ | elsif( Scalar::Util::blessed( $other ) && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
builtin::blessed($other) and $other->isa("DateTime::Lite::Duration") || $other->isa("DateTime::Duration") || $other->isa("Module::Generic::DateTime::Interval")
$other->isa("DateTime::Lite::Duration") or $other->isa("DateTime::Duration") or $other->isa("Module::Generic::DateTime::Interval")
$other->isa("DateTime::Lite::Duration") or $other->isa("DateTime::Duration")
MC/DC0%0/4
builtin::blessed($other) and $other->isa("DateTime::Lite::Duration") || $other->isa("DateTime::Duration") || $other->isa("Module::Generic::DateTime::Interval")
builtin::blessed($other)
$other->isa("DateTime::Lite::Duration")
$other->isa("DateTime::Duration")
$other->isa("Module::Generic::DateTime::Interval")
Truth table0%0/5
A and B or C or D
A= builtin::blessed($other)B= $other->isa("DateTime::Lite::Duration")C= $other->isa("DateTime::Duration")D= $other->isa("Module::Generic::DateTime::Interval")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | ( $other->isa( 'DateTime::Lite::Duration' ) || $other->isa( 'DateTime::Duration' ) || $other->isa( 'Module::Generic::DateTime::Interval' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | $other = $other->{interval} if( $other->isa( 'Module::Generic::DateTime::Interval' ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | ▶ | $res = $swap ? ( $other - $dur1 ) : ( $dur1 - $other ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | return( $self->_make_my_own( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | ▶ | elsif( !ref( $other ) || overload::Method( $other => '""' ) ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not ref $other or overload::Method($other, "\"\"")
MC/DC0%0/2
not ref $other or overload::Method($other, "\"\"")
not ref $other
overload::Method($other, "\"\"")
Truth table0%0/3
not(A) or B
A= not ref $otherB= overload::Method($other, "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | $other = $other + 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | my $d = $dur1->in_units( 'seconds' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | my $n = $swap ? ( $other - $d ) : ( $d - $other ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | $res = DateTime::Lite::Duration->new( seconds => $n ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | return( $self->_make_my_own( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | die( "Usupported data '", ref( $other ), "' in subtraction\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | sub _get_other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_other: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | my( $self, $other ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | if( Scalar::Util::blessed( $other ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | if( $other->isa( 'Module::Generic::DateTime' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | $other = $other->{dt}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | elsif( $other->isa( 'Module::Generic::DateTime::Interval' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | $other = $other->{interval}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 0 | return( $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | sub _make_my_own | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_my_own: called CC=7 SCAR=32.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 1 | my( $self, $res ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 1 | ▶ | if( Scalar::Util::blessed( $res ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
builtin::blessed($res) and $res->isa("DateTime::Lite::Duration") || $res->isa("DateTime::Duration")
$res->isa("DateTime::Lite::Duration") or $res->isa("DateTime::Duration")
MC/DC0%0/3
builtin::blessed($res) and $res->isa("DateTime::Lite::Duration") || $res->isa("DateTime::Duration")
builtin::blessed($res)
$res->isa("DateTime::Lite::Duration")
$res->isa("DateTime::Duration")
Truth table25%1/4
A and B or C
A= builtin::blessed($res)B= $res->isa("DateTime::Lite::Duration")C= $res->isa("DateTime::Duration")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | ( $res->isa( 'DateTime::Lite::Duration' ) || $res->isa( 'DateTime::Duration' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 1 | return( $self->new( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | ▶ | elsif( Scalar::Util::blessed( $res ) && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
builtin::blessed($res) and $res->isa("DateTime::Lite") || $res->isa("DateTime")
$res->isa("DateTime::Lite") or $res->isa("DateTime")
MC/DC0%0/3
builtin::blessed($res) and $res->isa("DateTime::Lite") || $res->isa("DateTime")
builtin::blessed($res)
$res->isa("DateTime::Lite")
$res->isa("DateTime")
Truth table0%0/4
A and B or C
A= builtin::blessed($res)B= $res->isa("DateTime::Lite")C= $res->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | ( $res->isa( 'DateTime::Lite' ) || $res->isa( 'DateTime' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | return( Module::Generic::DateTime->new( $res ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | return( $res ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | # NOTE: DESTROY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | DESTROY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | # <https://perldoc.perl.org/perlobj#Destructors> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 2 | CORE::local( $., $@, $!, $^E, $? ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | 2 | my $self = CORE::shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | 2 | ▶ | CORE::return if( Module::Generic::_in_global_destruction() ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 2 | ▶ | CORE::return if( !CORE::defined( $self ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 2 | ▶ | undef( $self->{interval} ) if( defined( $self->{interval} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | 2 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | # NOTE: AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | AUTOLOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=8 SCAR=38.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 0 | my( $method ) = our $AUTOLOAD =~ /([^:]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 5 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | my $class = ref( $self ) || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 0 | ▶ | die( "DateTime::Lite::Duration object is gone !\n" ) if( !ref( $self->{interval} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 5 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | my $dur = $self->{interval}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | ▶ | my $dt_dur_class = ref( $dur ) || 'DateTime::Lite::Duration'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
ref $dur || 'DateTime::Lite::Duration'
MC/DC0%0/1
ref $dur || 'DateTime::Lite::Duration'
ref $dur
Truth table0%0/2
A
A= ref $dur
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 0 | ▶ | $dt_dur_class = 'DateTime::Lite::Duration' unless( $dt_dur_class eq 'DateTime::Lite::Duration' || $dt_dur_class eq 'DateTime::Duration' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dt_dur_class eq "DateTime::Lite::Duration" or $dt_dur_class eq "DateTime::Duration"
MC/DC0%0/2
$dt_dur_class eq "DateTime::Lite::Duration" or $dt_dur_class eq "DateTime::Duration"
$dt_dur_class eq "DateTime::Lite::Duration"
$dt_dur_class eq "DateTime::Duration"
Truth table0%0/3
A or B
A= $dt_dur_class eq "DateTime::Lite::Duration"B= $dt_dur_class eq "DateTime::Duration"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | ▶ | if( $dur->can( $method ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 0 | $rv = $dur->$method( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 0 | return( $self->error( "Error trying to call ${dt_dur_class}::$method with arguments: '", join( "', '", @_ ), "': $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | return( $self->error( "No method \"$method\" available in ${dt_dur_class}" ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | # NOTE: FREEZE is inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_freeze: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | ▶ | sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORABLE_thaw: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | # NOTE: THAW is inherited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||