| 1 | package Rose::DateTime::Util; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Carp(); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use DateTime; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use DateTime::Infinite; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | our @EXPORT_OK = qw(format_date parse_date parse_european_date parse_epoch); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | our %EXPORT_TAGS = | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | std => [ qw(format_date parse_date parse_european_date) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | all => \@EXPORT_OK | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | our $VERSION = '0.540'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | our $TZ = 'floating'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | our $Debug = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | our $European_Dates = __PACKAGE__->init_european_dates; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | our $Error; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | sub error { $Error } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | sub time_zone | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time_zone: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 11 | my($class) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 11 | ▶ | return $TZ = shift if(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 7 | return $TZ; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | sub european_dates | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 14 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
european_dates: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 14 | my($class) = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 14 | ▶ | if(@_) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 9 | ▶ | if(defined $_[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 6 | ▶ | return $European_Dates = $_[0] ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | return $European_Dates = $class->init_european_dates; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | return $European_Dates; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | sub init_european_dates | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_european_dates: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | #my($class) = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | my $locale_class = DateTime->DefaultLocale; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | ▶ | unless(ref $locale_class) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $locale_class = DateTime::Locale->load($locale_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # Fall back to the older (pre-0.4) DateTime::Locale API | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 6 | ▶ | my $short = | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | $locale_class->can('date_format_short') ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | $locale_class->date_format_short : | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | $locale_class->short_date_format; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | $short =~ tr{dmyDMY}{}cd; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 6 | $short =~ tr{dmyDMY}{dmydmy}s; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # date_parts_order() is deprecated in DateTime::Locale 0.44+ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | #if($locale_class->date_parts_order eq 'dmy') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 6 | ▶ | if($short eq 'dmy') | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | sub parse_european_date | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 772 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_european_date: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 772 | local $European_Dates = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 772 | &parse_date; # implicitly pass the current args: @_ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | sub parse_date | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2774 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_date: called CC=27 SCAR=33.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2774 | my($arg, $time_zone) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2774 | ▶ | $time_zone ||= $TZ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$time_zone ||= $Rose::DateTime::Util::TZ
MC/DC0%0/2
$time_zone ||= $Rose::DateTime::Util::TZ
$time_zone
$Rose::DateTime::Util::TZ
Truth table66%2/3
A ||= B
A= $time_zoneB= $Rose::DateTime::Util::TZ
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2774 | my($fsecs, $secs, $mins, $hours, $mday, $month, $year, $wday, $yday, $isdst, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $month_abbrev, $date, $ampm, $hours2, $ampm2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2774 | $Error = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 3 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 2774 | ▶ | if(ref $arg && $arg->isa('DateTime')) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition66%2/3
ref $arg and $arg->isa("DateTime")
MC/DC50%1/2
ref $arg and $arg->isa("DateTime")
ref $arg
$arg->isa("DateTime")
Truth table66%2/3
A and B
A= ref $argB= $arg->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | ▶ | if(@_ > 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 2 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | TRY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | eval { $arg->set_time_zone($time_zone) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | if($error) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | $Error = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | return $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | elsif(($year, $month, $mday, $hours, $mins, $secs, $fsecs, $ampm, $hours2, $ampm2) = ($arg =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | (\d{4}) \s* [-._]? \s* # year | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | (\d{2}) \s* [-._]? \s* # month | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | (\d{2}) # day | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | \s* [-._T]? \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | (\d\d?) : # hour | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | (\d\d) # min | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | (?: (?: : (\d\d) )? (?: \. (\d{0,9}) )? )? # sec? nanosec? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | (?: \s* ([aApP]\.?[mM]\.?) )? # am/pm? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | (\d\d?) # hour | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | (?: \s* ([aApP]\.?[mM]\.?) ) # am/pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | }x)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # yyyy mm dd [hh:mm[:ss[.nnnnnnnnn]]] [am/pm] also valid w/o spaces or w/ hyphens | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 394 | ▶ | $hours = $hours2 if(defined $hours2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 394 | ▶ | $ampm = $ampm2 if(defined $ampm2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 394 | $date = _timelocal($secs, $mins, $hours, $mday, $month, $year, $ampm, $fsecs, $time_zone); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | elsif(($month, $mday, $year, $hours, $mins, $secs, $fsecs, $ampm) = ($arg =~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ^ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | (\d{1,2}) [-/._] (\d{1,2}) [-/._] (\d{4}) # xx-xx-yyyy | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | (?: \s+ | [-._T] ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | (\d\d?) # hour | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | (?::(\d\d)(?::(\d\d))?)?(?:\.(\d{0,9}))? # min? sec? nanosec? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | (?:\s*([aApP]\.?[mM]\.?))? # am/pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | )? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | $ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | }x)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # Normal: mm/dd/yyyy, mm-dd-yyyy, mm.dd.yyyy [hh:mm[:ss][.nnnnnnnnn]] [am/pm] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # European: dd/mm/yyyy, dd-mm-yyyy, dd.mm.yyyy [hh:mm[:ss][.nnnnnnnnn]] [am/pm] | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2364 | ▶ | if($European_Dates) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1546 | ($mday, $month) = ($month, $mday); # swap month and day in Euro-mode | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 2364 | $date = _timelocal($secs, $mins, $hours, $mday, $month, $year, $ampm, $fsecs, $time_zone); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ▶ | elsif(lc $arg eq 'now' || lc $arg eq 'now!') | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
lc $arg eq "now" or lc $arg eq "now!"
MC/DC50%1/2
lc $arg eq "now" or lc $arg eq "now!"
lc $arg eq "now"
lc $arg eq "now!"
Truth table66%2/3
A or B
A= lc $arg eq "now"B= lc $arg eq "now!"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # Right now | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | return DateTime->now(time_zone => $time_zone); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | elsif($arg =~ /^(?: (-?\d+)(?:\.(\d{0,9}))? | (-?\d*)\.(\d{1,9}) )$/x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 8 | ▶ | my $epoch = defined $1 ? $1 : $3; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 8 | ▶ | my $fsecs = defined $2 ? $2 : $4; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 8 | ▶ | $epoch = 0 if($epoch eq '-'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # In Unix time format (guessing) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 8 | ▶ | $date = DateTime->from_epoch(epoch => $epoch || 0, time_zone => $time_zone); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$epoch || 0
MC/DC100%1/1
$epoch || 0
$epoch
Truth table100%2/2
A
A= $epoch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 8 | ▶ | if($fsecs) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 6 | my $len = length $fsecs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 6 | ▶ | if($len < 9) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | $fsecs .= ('0' x (9 - length $fsecs)); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | elsif($len > 9) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $fsecs = substr($fsecs, 0, 9); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | $date->set(nanosecond => $fsecs); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 8 | return $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | elsif($arg =~ /^today$/i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | $date = DateTime->now(time_zone => $time_zone); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | $date->truncate(to => 'day'); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | elsif($arg =~ /^(-)?infinity$/i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | ▶ | if($1) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | return DateTime::Infinite::Past->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | return DateTime::Infinite::Future->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | ▶ | $Error = "Could not parse date: $arg" . | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | (($Error) ? " - $Error" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 2759 | ▶ | unless($date) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | $Error = "Could not parse date: $arg" . | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | (($Error) ? " - $Error" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 2759 | return $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | sub parse_epoch | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_epoch: called CC=12 SCAR=35.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | my($arg, $time_zone) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | ▶ | $time_zone ||= $TZ; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$time_zone ||= $Rose::DateTime::Util::TZ
MC/DC0%0/2
$time_zone ||= $Rose::DateTime::Util::TZ
$time_zone
$Rose::DateTime::Util::TZ
Truth table33%1/3
A ||= B
A= $time_zoneB= $Rose::DateTime::Util::TZ
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | $Error = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | my $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | ▶ | if($arg =~ /^(?: (-?\d+)(?:\.(\d{0,9}))? | (-?\d*)\.(\d{1,9}) )$/x) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | ▶ | my $epoch = defined $1 ? $1 : $3; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | ▶ | my $fsecs = defined $2 ? $2 : $4; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | $epoch = 0 if($epoch eq '-'); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # In Unix time format (guessing) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | ▶ | $date = DateTime->from_epoch(epoch => $epoch || 0, time_zone => $time_zone); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$epoch || 0
MC/DC0%0/1
$epoch || 0
$epoch
Truth table50%1/2
A
A= $epoch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | if($fsecs) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my $len = length $fsecs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if($len < 9) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $fsecs .= ('0' x (9 - length $fsecs)); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | elsif($len > 9) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $fsecs = substr($fsecs, 0, 9); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $date->set(nanosecond => $fsecs); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | return $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | return parse_date(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | unless($date) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | $Error = "Could not parse epoch: $arg" . | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | (($Error) ? " - $Error" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | return $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | sub format_date | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 74 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_date: called CC=13 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 74 | my($date, @formats) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 74 | my(@localtime, %formats, @ret, $ret); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 74 | ▶ | return undef unless(defined $date); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | #return $date if($date =~ /^-?infinity$/i); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 74 | ▶ | unless(ref $date && $date->isa('DateTime')) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $date and $date->isa("DateTime")
MC/DC0%0/2
ref $date and $date->isa("DateTime")
ref $date
$date->isa("DateTime")
Truth table33%1/3
A and B
A= ref $dateB= $date->isa("DateTime")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | Carp::croak("format_date() requires a DateTime object as its first argument"); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 74 | ▶ | return '-infinity' if($date->isa('DateTime::Infinite::Past')); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 73 | ▶ | return 'infinity' if($date->isa('DateTime::Infinite::Future')); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 72 | foreach my $format (@formats) | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 74 | $format =~ s/%t/%l:%M:%S %p/g; # strftime() treats %t as a \t | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # Formats not handled by strftime() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 74 | ▶ | if($format =~ /%[EFf]/) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 31 | ▶ | unless(%formats) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 31 | my $date_word; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 31 | my $mday = $date->day; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | #if($mday =~ /([^1]|^)1$/) { $date_word = $mday . 'st' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | #elsif($mday =~ /([^1]|^)2$/) { $date_word = $mday . 'nd' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | #elsif($mday =~ /([^1]|^)3$/) { $date_word = $mday . 'rd' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | #else { $date_word = $mday . 'th' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # Requires a reasonably modern perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 31 | ▶ | if($mday =~ /(?<!1)1$/) { $date_word = $mday . 'st' } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 2 | elsif($mday =~ /(?<!1)2$/) { $date_word = $mday . 'nd' } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 2 | elsif($mday =~ /(?<!1)3$/) { $date_word = $mday . 'rd' } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 24 | else { $date_word = $mday . 'th' } | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 31 | %formats = | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | #'%e' => $mday, # DateTime snagged this one | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | '%E' => $date_word, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | '%F' => $date->strftime("%A, %B $date_word %Y"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | '%f' => $date->month + 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 31 | $format =~ s/(%[eEFf])/$formats{$1}/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 74 | push(@ret, $date->strftime($format)); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 72 | ▶ | return wantarray ? @ret : join(' ', @ret); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # Internal Subroutines | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | sub _timelocal | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 2758 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_timelocal: called CC=13 SCAR=26.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 2758 | my($secs, $mins, $hours, $mday, $month, $year, $ampm, $fsecs, $tz) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 2758 | my($date); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 2758 | ▶ | $hours = 0 unless(defined($hours)); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 2758 | ▶ | if(defined $fsecs) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 2022 | my $len = length $fsecs; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 2022 | ▶ | if($len < 9) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1348 | $fsecs .= ('0' x (9 - length $fsecs)); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | elsif($len > 9) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | $fsecs = substr($fsecs, 0, 9); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 736 | $fsecs = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 2758 | ▶ | $secs = 0 unless(defined $secs); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 2758 | ▶ | $mins = 0 unless(defined $mins); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2758 | ▶ | if($ampm) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 1352 | ▶ | if($ampm =~ /^p/i) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1349 | ▶ | $hours += 12 unless($hours == 12); | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | elsif($hours == 12) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $hours = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 2758 | my $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | TRY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 2758 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 2758 | { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 2758 | $date = DateTime->new(year => $year, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | month => $month, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | day => $mday, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | hour => $hours, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | minute => $mins, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | second => $secs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | nanosecond => $fsecs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | time_zone => $tz); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 2758 | $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2758 | ▶ | if($error) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $Error = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | warn $Error if($Debug); # $ENV{'MOD_PERL'} | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 2758 | return $date; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # Can't figure out how to hide comments like this from search.cpan.org's | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # POD-to-HTML translator... | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # =begin comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | # B<PLEASE NOTE:> The local time zone may not be known on all systems (in | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | # particular, Win32 systems). If you are on such a system, you will encounter a | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # fatal error if C<parse_date()> tries to construct a L<DateTime> object with | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | # a time zone of "local". | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | # See the L<DateTime::TimeZone> documentation for information on the various | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | # ways to successfully indicate your local time zone, or set a different default | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | # time zone for this class by calling | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # L<Rose::DateTime::Util-E<gt>time_zone(...)> with a new time zone as an | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # argument. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # =end comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||