ParseDate.pm

filter: Statementstmt 34.8% 166 / 477 Branchbran 17.4% 87 / 498 Conditioncond 16.6% 48 / 289 MC/DCmcdc 2.7% 4 / 148 Subroutinesub 66.6% 14 / 21 Podpod 0.0% 0 / 13 totaltotal 22.0% 319 / 1446 CC 351 SCAR 80.8
CC
351
Cov
24%
parsedate
6574.7
parse_date_only
2184.0
parse_date_offset
1892.0
CRAP 3228.1
↑ Summary Timezone.pm »
1 package Time::ParseDate;
2  
3 5 require 5.008001;
4  
5 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Time::Timezone;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use Time::JulianDay;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 require Exporter;
9 5 @ISA = qw(Exporter);
10 5 @EXPORT = qw(parsedate);
11 5 @EXPORT_OK = qw(pd_raw %mtable %umult %wdays);
12  
13 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 #use diagnostics;
15  
16 # constants
17 5 ▶use vars qw(%mtable %umult %wdays $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 5 $VERSION = 2026.0330;
20  
21 # globals
22 5 ▶use vars qw($debug);
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 # dynamically-scoped
25 5 ▶use vars qw($parse);
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 5 my %mtable;
28 my %umult;
29 5 my %wdays;
30 5 my $y2k;
31  
32 CONFIG: {
33  
34 5 %mtable = qw(
35 Jan 1 Jan. 1 January 1
36 Feb 2 Feb. 2 February 2
37 Mar 3 Mar. 3 March 3
38 Apr 4 Apr. 4 April 4
39 May 5
40 Jun 6 Jun. 6 June 6
41 Jul 7 Jul. 7 July 7
42 Aug 8 Aug. 8 August 8
43 Sep 9 Sep. 9 September 9 Sept 9
44 Oct 10 Oct. 10 October 10
45 Nov 11 Nov. 11 November 11
46 Dec 12 Dec. 12 December 12 );
47 5 %umult = qw(
48 sec 1 second 1
49 min 60 minute 60
50 hour 3600
51 day 86400
52 week 604800
53 fortnight 1209600);
54 5 %wdays = qw(
55 sun 0 sunday 0
56 mon 1 monday 1
57 tue 2 tuesday 2
58 wed 3 wednesday 3
59 thu 4 thursday 4
60 fri 5 friday 5
61 sat 6 saturday 6
62 );
63  
64 5 $y2k = 946684800; # turn of the century
65 }
66  
67 5 my $break = qr{(?:\s+|\Z|\b(?![-:.,/]\d))};
68  
69 sub parsedate
70 14 ▶{
Subroutine parsedate: called CC=149 SCAR=87.9
Pod undocumented
71 14 my ($t, %options) = @_;
72  
73 14 my ($y, $m, $d); # year, month - 1..12, day
74 14 my ($H, $M, $S); # hour, minute, second
75 14 my $tz; # timezone
76 14 my $tzo; # timezone offset
77 14 my ($rd, $rs); # relative days, relative seconds
78  
79 14 my $rel; # time&|date is relative
80  
81 14 my $isspec;
82 14 ▶ my $now = defined($options{NOW}) ? $options{NOW} : time;
Branch: 1 branch
BranchTrueFalseTotal
defined $options{'NOW'} ? : 0 14 14
83 14 my $passes = 0;
84 14 ▶ my $uk = defined($options{UK}) ? $options{UK} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $options{'UK'} ? : 0 14 14
85  
86 14 local $parse = ''; # will be dynamically scoped.
87  
88 14 ▶ if ($t =~ s#^ ([ \d]\d)
Branch: 2 branches
BranchTrueFalseTotal
if ($t =~ s[^ ([ \d]\d) / (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) / (\d\d\d\d) : (\d\d) : (\d\d) : (\d\d) (?: [ ] ([-+] \d\d\d\d) (?: \("?(?:(?:[A-Z]{1,4}[TCW56])|IDLE)\))? )? $break ][]xi) { } 0 14 14
elsif ($t =~ s[^(\d\d)/(\d\d)/(\d\d)\.(\d\d)\:(\d\d)($break)][]) { } 0 14 14
89 / (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)
90 / (\d\d\d\d)
91 : (\d\d)
92 : (\d\d)
93 : (\d\d)
94 (?:
95 [ ]
96 ([-+] \d\d\d\d)
97 (?: \("?(?:(?:[A-Z]{1,4}[TCW56])|IDLE)\))?
98 )?
99 $break
100 ##xi) { #"emacs
101 # [ \d]/Mon/yyyy:hh:mm:ss [-+]\d\d\d\d
102 # This is the format for www server logging.
103  
104 0 ▶ ($d, $m, $y, $H, $M, $S, $tzo) = ($1, $mtable{"\u\L$2"}, $3, $4, $5, $6, $7 ? &mkoff($7) : ($tzo || undef));
Branch: 1 branch
BranchTrueFalseTotal
$7 ? : 0 0 0
Condition0%0/2
$tzo or undef
l!l
00
MC/DC0%0/1
$tzo or undef
$tzo
Truth table0%0/2
A
A= $tzo
Aresult
11
00
105 0 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
106 } elsif ($t =~ s#^(\d\d)/(\d\d)/(\d\d)\.(\d\d)\:(\d\d)($break)##) {
107 # yy/mm/dd.hh:mm
108 # I support this format because it's used by wbak/rbak
109 # on Apollo Domain OS. Silly, but historical.
110  
111 0 ($y, $m, $d, $H, $M, $S) = ($1, $2, $3, $4, $5, 0);
112 0 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
113 } else {
114 14 while(1) {
115 40 ▶ if (! defined $m and ! defined $rd and ! defined $y
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $m or defined $rd or defined $y or $passes == 0 and $options{"TIMEFIRST"}) 14 26 40
Condition58%7/12
defined $m or defined $rd or defined $y or $passes == 0 and $options{"TIMEFIRST"}
l!l&&r!l&&!r
26014
defined $m or defined $rd or defined $y
l!l&&r!l&&!r
26014
defined $m or defined $rd
l!l&&r!l&&!r
26014
$passes == 0 and $options{"TIMEFIRST"}
!ll&&!rl&&r
0140
MC/DC20%1/5
defined $m or defined $rd or defined $y or $passes == 0 and $options{"TIMEFIRST"}
defined $m defined $rd defined $y $passes == 0 $options{"TIMEFIRST"}
Truth table33%2/6
A or B or C or D and E
A= defined $mB= defined $rdC= defined $yD= $passes == 0E= $options{"TIMEFIRST"}
ABCDEresult
1XXXX1
01XXX1
001XX1
000111
0000X0
000100
116 and ! ($passes == 0 and $options{'TIMEFIRST'}))
117 {
118 # no month defined.
119 14 ▶ if (&parse_date_only(\$t, \$y, \$m, \$d, $uk)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&parse_date_only(\$t, \$y, \$m, \$d, $uk)) 14 0 14
120 14 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 14 14
121 14 next;
122 }
123 }
124 26 ▶ if (! defined $H and ! defined $rs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $H or defined $rs) 14 12 26
Condition66%2/3
defined $H or defined $rs
l!l&&r!l&&!r
12014
MC/DC50%1/2
defined $H or defined $rs
defined $H defined $rs
Truth table66%2/3
A or B
A= defined $HB= defined $rs
ABresult
1X1
011
000
125 14 ▶ if (&parse_time_only(\$t, \$H, \$M, \$S,
Branch: 1 branch
BranchTrueFalseTotal
if (&parse_time_only(\$t, \$H, \$M, \$S, \$tz, %options)) 6 8 14
126 \$tz, %options))
127 {
128 6 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 6 6
129 6 next;
130 }
131 }
132 20 ▶ next if $passes == 0 and $options{'TIMEFIRST'};
Branch: 1 branch
BranchTrueFalseTotal
if $passes == 0 and $options{"TIMEFIRST"} 0 20 20
Condition33%1/3
$passes == 0 and $options{"TIMEFIRST"}
!ll&&!rl&&r
2000
MC/DC0%0/2
$passes == 0 and $options{"TIMEFIRST"}
$passes == 0 $options{"TIMEFIRST"}
Truth table33%1/3
A and B
A= $passes == 0B= $options{"TIMEFIRST"}
ABresult
0X0
100
111
133 20 ▶ if (! defined $y) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $y) 6 14 20
134 6 ▶ if (&parse_year_only(\$t, \$y, $now, %options)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&parse_year_only(\$t, \$y, $now, %options)) 6 0 6
135 6 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 6 6
136 6 next;
137 }
138 }
139 14 ▶ if (! defined $tz and ! defined $tzo and ! defined $rs
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $tz || defined $tzo || defined $rs and defined $m || defined $H) 14 0 14
Condition33%4/12
not defined $tz || defined $tzo || defined $rs and defined $m || defined $H
!ll&&!rl&&r
0014
defined $tz || defined $tzo || defined $rs
l!l&&r!l&&!r
0014
defined $tz or defined $tzo
l!l&&r!l&&!r
0014
defined $m or defined $H
l!l&&r!l&&!r
1400
MC/DC0%0/5
not defined $tz || defined $tzo || defined $rs and defined $m || defined $H
defined $tz defined $tzo defined $rs defined $m defined $H
Truth table16%1/6
not(A or B || C) and D or E
A= defined $tzB= defined $tzoC= defined $rsD= defined $mE= defined $H
ABCDEresult
1XXXX0
01XXX0
001XX0
000000
0001X1
000011
140 and (defined $m or defined $H))
141 {
142 14 ▶ if (&parse_tz_only(\$t, \$tz, \$tzo)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&parse_tz_only(\$t, \$tz, \$tzo)) 0 14 14
143 0 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
144 0 next;
145 }
146 }
147 14 ▶ if (! defined $H and ! defined $rs) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $H or defined $rs) 8 6 14
Condition66%2/3
defined $H or defined $rs
l!l&&r!l&&!r
608
MC/DC50%1/2
defined $H or defined $rs
defined $H defined $rs
Truth table66%2/3
A or B
A= defined $HB= defined $rs
ABresult
1X1
011
000
148 8 ▶ if (&parse_time_offset(\$t, \$rs, %options)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&parse_time_offset(\$t, \$rs, %options)) 0 8 8
149 0 $rel = 1;
150 0 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
151 0 next;
152 }
153 }
154 14 ▶ if (! defined $m and ! defined $rd and ! defined $y) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $m or defined $rd or defined $y) 0 14 14
Condition33%2/6
defined $m or defined $rd or defined $y
l!l&&r!l&&!r
1400
defined $m or defined $rd
l!l&&r!l&&!r
1400
MC/DC0%0/3
defined $m or defined $rd or defined $y
defined $m defined $rd defined $y
Truth table25%1/4
A or B or C
A= defined $mB= defined $rdC= defined $y
ABCresult
1XX1
01X1
0011
0000
155 0 ▶ if (&parse_date_offset(\$t, $now, \$y,
Branch: 1 branch
BranchTrueFalseTotal
if (&parse_date_offset(\$t, $now, \$y, \$m, \$d, \$rd, \$rs, %options)) 0 0 0
156 \$m, \$d, \$rd, \$rs, %options))
157 {
158 0 $rel = 1;
159 0 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
160 0 next;
161 }
162 }
163 14 ▶ if (defined $M or defined $rd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $M or defined $rd) 6 8 14
Condition66%2/3
defined $M or defined $rd
l!l&&r!l&&!r
608
MC/DC50%1/2
defined $M or defined $rd
defined $M defined $rd
Truth table66%2/3
A or B
A= defined $MB= defined $rd
ABresult
1X1
011
000
164 6 ▶ if ($t =~ s/^\s*(?:at|\@|\+)($break)//x) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t =~ s/^\s*(?:at|\@|\+)($break)//x) 0 6 6
165 0 $rel = 1;
166 0 ▶ $parse .= " ".__LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
167 0 next;
168 }
169 }
170 14 last;
171 } continue {
172 26 $passes++;
173 26 ▶ &debug_display($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 26 26
174  
175 }
176  
177 14 ▶ if ($passes == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($passes == 0) 0 14 14
178 0 ▶ print "nothing matched\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
179 0 ▶ return (undef, "no match on time/date")
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
180 if wantarray();
181 0 return undef;
182 }
183 }
184  
185 14 ▶ &debug_display($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 14 14
186  
187 14 $t =~ s/^\s+//;
188  
189 14 ▶ if ($t ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($t ne "") 0 14 14
190 # we didn't manage to eat the string
191 0 ▶ print "NOT WHOLE\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
192 0 ▶ if ($options{WHOLE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"WHOLE"}) 0 0 0
193 0 ▶ return (undef, "characters left over after parse")
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
194 if wantarray();
195 return undef
196 0 }
197 }
198  
199 # define a date if there isn't one already
200  
201 14 ▶ if (! defined $y and ! defined $m and ! defined $rd) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $y or defined $m or defined $rd) 0 14 14
Condition33%2/6
defined $y or defined $m or defined $rd
l!l&&r!l&&!r
1400
defined $y or defined $m
l!l&&r!l&&!r
1400
MC/DC0%0/3
defined $y or defined $m or defined $rd
defined $y defined $m defined $rd
Truth table25%1/4
A or B or C
A= defined $yB= defined $mC= defined $rd
ABCresult
1XX1
01X1
0011
0000
202 0 ▶ print "no date defined, trying to find one." if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
203 0 ▶ if (defined $rs or defined $H) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rs or defined $H) { } 0 0 0
Condition0%0/3
defined $rs or defined $H
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $rs or defined $H
defined $rs defined $H
Truth table0%0/3
A or B
A= defined $rsB= defined $H
ABresult
1X1
011
000
204 # we do have a time.
205 0 ▶ if ($options{DATE_REQUIRED}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"DATE_REQUIRED"}) 0 0 0
206 0 ▶ return (undef, "no date specified")
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
207 if wantarray();
208 0 return undef;
209 }
210 0 ▶ if (defined $rs) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rs) 0 0 0
211 0 ▶ print "simple offset: $rs\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
212 0 my $rv = $now + $rs;
213 0 ▶ return ($rv, $t) if wantarray();
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
214 0 return $rv;
215 }
216 0 $rd = 0;
217 } else {
218 0 ▶ print "no time either!\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
219 0 ▶ return (undef, "no time specified")
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
220 if wantarray();
221 0 return undef;
222 }
223 }
224  
225 14 ▶ if ($options{TIME_REQUIRED} && ! defined($rs)
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"TIME_REQUIRED"} and not defined $rs and not defined $H and not defined $rd) 0 14 14
Condition33%3/9
$options{"TIME_REQUIRED"} and not defined $rs and not defined $H and not defined $rd
!ll&&!rl&&r
1400
$options{"TIME_REQUIRED"} and not defined $rs and not defined $H
!ll&&!rl&&r
1400
$options{"TIME_REQUIRED"} and not defined $rs
!ll&&!rl&&r
1400
MC/DC0%0/4
$options{"TIME_REQUIRED"} and not defined $rs and not defined $H and not defined $rd
$options{"TIME_REQUIRED"} not defined $rs not defined $H not defined $rd
Truth table20%1/5
A and not(B) and not(C) and not(D)
A= $options{"TIME_REQUIRED"}B= not defined $rsC= not defined $HD= not defined $rd
ABCDresult
0XXX0
10XX0
110X0
11100
11111
226 && ! defined($H) && ! defined($rd))
227 {
228 0 ▶ return (undef, "no time found")
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
229 if wantarray();
230 0 return undef;
231 }
232  
233 14 my $secs;
234 my $jd;
235  
236 14 ▶ if (defined $rd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rd) { } 0 14 14
237 0 ▶ if (defined $rs || ! (defined($H) || defined($M) || defined($S))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rs or not defined $H || defined $M || defined $S) 0 0 0
Condition0%0/9
defined $rs or not defined $H || defined $M || defined $S
l!l&&r!l&&!r
000
defined $H || defined $M || defined $S
l!l&&r!l&&!r
000
defined $H or defined $M
l!l&&r!l&&!r
000
MC/DC0%0/4
defined $rs or not defined $H || defined $M || defined $S
defined $rs defined $H defined $M defined $S
Truth table0%0/5
A or not(B or C || D)
A= defined $rsB= defined $HC= defined $MD= defined $S
ABCDresult
1XXX1
00001
01XX0
001X0
00010
238 0 ▶ print "fully relative\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
239 0 my ($j, $in, $it);
240 0 ▶ my $definedrs = defined($rs) ? $rs : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $rs ? : 0 0 0
241 0 my ($isdst_now, $isdst_then);
242 0 my $r = $now + $rd * 86400 + $definedrs;
243 #
244 # It's possible that there was a timezone shift
245 # during the time specified. If so, keep the
246 # hours the "same".
247 #
248 0 $isdst_now = (localtime($r))[8];
249 0 $isdst_then = (localtime($now))[8];
250 0 ▶ if (($isdst_now == $isdst_then) || $options{GMT})
Branch: 1 branch
BranchTrueFalseTotal
if ($isdst_now == $isdst_then or $options{"GMT"}) 0 0 0
Condition0%0/3
$isdst_now == $isdst_then or $options{"GMT"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$isdst_now == $isdst_then or $options{"GMT"}
$isdst_now == $isdst_then $options{"GMT"}
Truth table0%0/3
A or B
A= $isdst_now == $isdst_thenB= $options{"GMT"}
ABresult
1X1
011
000
251 {
252 0 ▶ return ($r, $t) if wantarray();
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
253 0 return $r
254 }
255
256 0 ▶ print "localtime changed DST during time period!\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
257 }
258  
259 0 ▶ print "relative date\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
260 $jd = $options{GMT}
261 0 ▶ ? gm_julian_day($now)
Branch: 1 branch
BranchTrueFalseTotal
$options{'GMT'} ? : 0 0 0
262 : local_julian_day($now);
263 0 ▶ print "jd($now) = $jd\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
264 0 $jd += $rd;
265 } else {
266 14 ▶ unless (defined $y) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $y) 0 14 14
267 0 ▶ if ($options{PREFER_PAST}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($options{'PREFER_PAST'}) { } 0 0 0
elsif ($options{'PREFER_FUTURE'}) { } 0 0 0
268 0 my ($day, $mon011);
269 0 ($day, $mon011, $y) = (&righttime($now))[3,4,5];
270  
271 0 ▶ print "calc year -past $day-$d $mon011-$m $y\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
272 0 ▶ $y -= 1 if ($mon011+1 < $m) ||
Branch: 1 branch
BranchTrueFalseTotal
if $mon011 + 1 < $m or $mon011 + 1 == $m and $day < $d 0 0 0
Condition0%0/6
$mon011 + 1 < $m or $mon011 + 1 == $m and $day < $d
l!l&&r!l&&!r
000
$mon011 + 1 == $m and $day < $d
!ll&&!rl&&r
000
MC/DC0%0/3
$mon011 + 1 < $m or $mon011 + 1 == $m and $day < $d
$mon011 + 1 < $m $mon011 + 1 == $m $day < $d
Truth table0%0/4
A or B and C
A= $mon011 + 1 < $mB= $mon011 + 1 == $mC= $day < $d
ABCresult
1XX1
0111
00X0
0100
273 (($mon011+1 == $m) && ($day < $d));
274 } elsif ($options{PREFER_FUTURE}) {
275 0 ▶ print "calc year -future\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
276 0 my ($day, $mon011);
277 0 ($day, $mon011, $y) = (&righttime($now))[3,4,5];
278 0 ▶ $y += 1 if ($mon011 >= $m) ||
Branch: 1 branch
BranchTrueFalseTotal
if $mon011 >= $m or $mon011 + 1 == $m and $day > $d 0 0 0
Condition0%0/6
$mon011 >= $m or $mon011 + 1 == $m and $day > $d
l!l&&r!l&&!r
000
$mon011 + 1 == $m and $day > $d
!ll&&!rl&&r
000
MC/DC0%0/3
$mon011 >= $m or $mon011 + 1 == $m and $day > $d
$mon011 >= $m $mon011 + 1 == $m $day > $d
Truth table0%0/4
A or B and C
A= $mon011 >= $mB= $mon011 + 1 == $mC= $day > $d
ABCresult
1XX1
0111
00X0
0100
279 (($mon011+1 == $m) && ($day > $d));
280 } else {
281 0 ▶ print "calc year -this\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
282 0 $y = (localtime($now))[5];
283 }
284 0 $y += 1900;
285 }
286  
287 14 ▶ $y = expand_two_digit_year($y, $now, %options)
Branch: 1 branch
BranchTrueFalseTotal
if $y < 100 0 14 14
288 if $y < 100;
289  
290 14 ▶ if ($options{VALIDATE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"VALIDATE"}) 0 14 14
291 0 require Time::DaysInMonth;
292 0 my $dim = Time::DaysInMonth::days_in($y, $m);
293 0 ▶ if ($y < 1000 or $m < 1 or $d < 1
Branch: 1 branch
BranchTrueFalseTotal
if ($y < 1000 or $m < 1 or $d < 1 or $y > 9999 or $m > 12 or $d > $dim) 0 0 0
Condition0%0/15
$y < 1000 or $m < 1 or $d < 1 or $y > 9999 or $m > 12 or $d > $dim
l!l&&r!l&&!r
000
$y < 1000 or $m < 1 or $d < 1 or $y > 9999 or $m > 12
l!l&&r!l&&!r
000
$y < 1000 or $m < 1 or $d < 1 or $y > 9999
l!l&&r!l&&!r
000
$y < 1000 or $m < 1 or $d < 1
l!l&&r!l&&!r
000
$y < 1000 or $m < 1
l!l&&r!l&&!r
000
MC/DC0%0/6
$y < 1000 or $m < 1 or $d < 1 or $y > 9999 or $m > 12 or $d > $dim
$y < 1000 $m < 1 $d < 1 $y > 9999 $m > 12 $d > $dim
Truth table0%0/7
A or B or C or D or E or F
A= $y < 1000B= $m < 1C= $d < 1D= $y > 9999E= $m > 12F= $d > $dim
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
294 or $y > 9999 or $m > 12 or $d > $dim)
295 {
296 0 ▶ return (undef, "illegal YMD: $y, $m, $d")
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
297 if wantarray();
298 0 return undef;
299 }
300 }
301 14 $jd = julian_day($y, $m, $d);
302 14 ▶ print "jd($y, $m, $d) = $jd\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 14 14
303 }
304  
305 # put time into HMS
306  
307 14 ▶ if (! defined($H)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $H) 8 6 14
308 8 ▶ if (defined($rd) || defined($rs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rd or defined $rs) 0 8 8
Condition33%1/3
defined $rd or defined $rs
l!l&&r!l&&!r
008
MC/DC0%0/2
defined $rd or defined $rs
defined $rd defined $rs
Truth table33%1/3
A or B
A= defined $rdB= defined $rs
ABresult
1X1
011
000
309 0 ($S, $M, $H) = &righttime($now, %options);
310 0 ▶ print "HMS set to $H $M $S\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
311 }
312 }
313  
314 14 my $carry;
315  
316 14 ▶ print "before ", (defined($rs) ? "$rs" : ""),
Branch: 2 branches
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 14 14
defined $rs ? : 0 0 0
317 " $jd $H $M $S\n"
318 if $debug;
319 #
320 # add in relative seconds. Do it this way because we want to
321 # preserve the localtime across DST changes.
322 #
323  
324 14 ▶ $S = 0 unless $S; # -w
Branch: 1 branch
BranchTrueFalseTotal
unless $S 8 6 14
325 14 ▶ $M = 0 unless $M; # -w
Branch: 1 branch
BranchTrueFalseTotal
unless $M 8 6 14
326 14 ▶ $H = 0 unless $H; # -w
Branch: 1 branch
BranchTrueFalseTotal
unless $H 8 6 14
327  
328 14 ▶ if ($options{VALIDATE} and
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"VALIDATE"} and $S < 0 || $M < 0 || $H < 0 || $S > 59 || $M > 59 || $H > 23) 0 14 14
Condition5%1/18
$options{"VALIDATE"} and $S < 0 || $M < 0 || $H < 0 || $S > 59 || $M > 59 || $H > 23
!ll&&!rl&&r
1400
$S < 0 or $M < 0 or $H < 0 or $S > 59 or $M > 59 or $H > 23
l!l&&r!l&&!r
000
$S < 0 or $M < 0 or $H < 0 or $S > 59 or $M > 59
l!l&&r!l&&!r
000
$S < 0 or $M < 0 or $H < 0 or $S > 59
l!l&&r!l&&!r
000
$S < 0 or $M < 0 or $H < 0
l!l&&r!l&&!r
000
$S < 0 or $M < 0
l!l&&r!l&&!r
000
MC/DC0%0/7
$options{"VALIDATE"} and $S < 0 || $M < 0 || $H < 0 || $S > 59 || $M > 59 || $H > 23
$options{"VALIDATE"} $S < 0 $M < 0 $H < 0 $S > 59 $M > 59 $H > 23
Truth table12%1/8
A and B or C or D or E or F or G
A= $options{"VALIDATE"}B= $S < 0C= $M < 0D= $H < 0E= $S > 59F= $M > 59G= $H > 23
ABCDEFGresult
0XXXXXX0
10000000
11XXXXX1
101XXXX1
1001XXX1
10001XX1
100001X1
10000011
329 ($S < 0 or $M < 0 or $H < 0 or $S > 59 or $M > 59 or $H > 23))
330 {
331 0 ▶ return (undef, "illegal HMS: $H, $M, $S") if wantarray();
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
332 0 return undef;
333 }
334  
335 14 ▶ $S += $rs if defined $rs;
Branch: 1 branch
BranchTrueFalseTotal
if defined $rs 0 14 14
336 14 ▶ $carry = int($S / 60) - ($S < 0 && $S % 60 && 1);
Condition40%2/5
$S < 0 && $S % 60 && 1
!ll
140
$S < 0 and $S % 60
!ll&&!rl&&r
1400
MC/DC0%0/2
$S < 0 && $S % 60 && 1
$S < 0 $S % 60
Truth table33%1/3
A and B
A= $S < 0B= $S % 60
ABresult
0X0
100
111
337 14 $S -= $carry * 60;
338 14 $M += $carry;
339 14 ▶ $carry = int($M / 60) - ($M < 0 && $M % 60 && 1);
Condition40%2/5
$M < 0 && $M % 60 && 1
!ll
140
$M < 0 and $M % 60
!ll&&!rl&&r
1400
MC/DC0%0/2
$M < 0 && $M % 60 && 1
$M < 0 $M % 60
Truth table33%1/3
A and B
A= $M < 0B= $M % 60
ABresult
0X0
100
111
340 14 $M %= 60;
341 14 $H += $carry;
342 14 ▶ $carry = int($H / 24) - ($H < 0 && $H % 24 && 1);
Condition40%2/5
$H < 0 && $H % 24 && 1
!ll
140
$H < 0 and $H % 24
!ll&&!rl&&r
1400
MC/DC0%0/2
$H < 0 && $H % 24 && 1
$H < 0 $H % 24
Truth table33%1/3
A and B
A= $H < 0B= $H % 24
ABresult
0X0
100
111
343 14 $H %= 24;
344 14 $jd += $carry;
345  
346 14 ▶ print "after rs $jd $H $M $S\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 14 14
347  
348 14 $secs = jd_secondsgm($jd, $H, $M, $S);
349 14 ▶ print "jd_secondsgm($jd, $H, $M, $S) = $secs\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 14 14
350  
351 #
352 # If we see something link 3pm CST then and we want to end
353 # up with a GMT seconds, then we convert the 3pm to GMT and
354 # subtract in the offset for CST. We subtract because we
355 # are converting from CST to GMT.
356 #
357 14 my $tzadj;
358 14 ▶ if ($tz) {
Branch: 2 branches
BranchTrueFalseTotal
if ($tz) { } 0 14 14
elsif (defined $tzo) { } 0 14 14
359 0 $tzadj = tz_offset($tz, $secs);
360 0 ▶ if (defined $tzadj) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tzadj) { } 0 0 0
361 0 ▶ print "adjusting secs for $tz: $tzadj\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
362 0 $tzadj = tz_offset($tz, $secs-$tzadj);
363 0 $secs -= $tzadj;
364 } else {
365 0 ▶ print "unknown timezone: $tz\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
366 0 undef $secs;
367 0 undef $t;
368 }
369 } elsif (defined $tzo) {
370 0 ▶ print "adjusting time for offset: $tzo\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
371 0 $secs -= $tzo;
372 } else {
373 14 ▶ unless ($options{GMT}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($options{"GMT"}) 14 0 14
374 14 ▶ if ($options{ZONE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'ZONE'}) { } 0 14 14
375 0 ▶ $tzadj = tz_offset($options{ZONE}, $secs) || 0;
Condition0%0/2
tz_offset($options{'ZONE'}, $secs) || 0
l!l
00
MC/DC0%0/1
tz_offset($options{'ZONE'}, $secs) || 0
tz_offset($options{'ZONE'}, $secs)
Truth table0%0/2
A
A= tz_offset($options{'ZONE'}, $secs)
Aresult
11
00
376 0 $tzadj = tz_offset($options{ZONE}, $secs-$tzadj);
377 0 ▶ unless (defined($tzadj)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $tzadj) 0 0 0
378 0 ▶ return (undef, "could not convert '$options{ZONE}' to time offset")
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 0 0
379 if wantarray();
380 0 return undef;
381 }
382 0 ▶ print "adjusting secs for $options{ZONE}: $tzadj\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
383 0 $secs -= $tzadj;
384 } else {
385 14 $tzadj = tz_local_offset($secs);
386 14 ▶ print "adjusting secs for local offset: $tzadj\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 14 14
387 #
388 # Just in case we are very close to a time
389 # change...
390 #
391 14 $tzadj = tz_local_offset($secs-$tzadj);
392 14 $secs -= $tzadj;
393 }
394 }
395 }
396  
397 14 ▶ print "returning $secs.\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 14 14
398  
399 14 ▶ return ($secs, $t) if wantarray();
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 14 14
400 14 return $secs;
401 }
402  
403  
404 sub mkoff
405 0 ▶{
Subroutine mkoff: not called CC=4 SCAR=30.0
Pod undocumented
406 0 my($offset) = @_;
407  
408 0 ▶ if (defined $offset and $offset =~ s#^([-+])(\d\d):?(\d\d)$##) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $offset and $offset =~ s/^([-+])(\d\d):?(\d\d)$//) 0 0 0
Condition0%0/3
defined $offset and $offset =~ s/^([-+])(\d\d):?(\d\d)$//
!ll&&!rl&&r
000
MC/DC0%0/2
defined $offset and $offset =~ s/^([-+])(\d\d):?(\d\d)$//
defined $offset $offset =~ s/^([-+])(\d\d):?(\d\d)$//
Truth table0%0/3
A and B
A= defined $offsetB= $offset =~ s/^([-+])(\d\d):?(\d\d)$//
ABresult
0X0
100
111
409 0 ▶ return ($1 eq '+' ?
Branch: 1 branch
BranchTrueFalseTotal
$1 eq '+' ? : 0 0 0
410 3600 * $2 + 60 * $3
411 : -3600 * $2 + -60 * $3 );
412 }
413 0 return undef;
414 }
415  
416 sub parse_tz_only
417 14 ▶{
Subroutine parse_tz_only: called CC=14 SCAR=48.3
Pod undocumented
418 14 my($tr, $tz, $tzo) = @_;
419  
420 14 $$tr =~ s#^\s+##;
421 14 my $o;
422  
423 14 ▶ if ($$tr =~ s#^
Branch: 4 branches
BranchTrueFalseTotal
if ($$tr =~ s/^ ([-+]\d\d:?\d\d) \s+ \( "? (?: (?: [A-Z]{1,4}[TCW56] ) | IDLE ) \) $break //x) { } 0 14 14
elsif ($$tr =~ s/^GMT\s*([-+]\d{1,2})($break)//x) { } 0 14 14
elsif ($$tr =~ s/^(?:GMT\s*)?([-+]\d\d:?\d\d)($break)//x) { } 0 14 14
elsif ($$tr =~ s/^"?((?:[A-Z]{1,4}[TCW56])|IDLE)$break//x) { } 0 14 14
424 ([-+]\d\d:?\d\d)
425 \s+
426 \(
427 "?
428 (?:
429 (?:
430 [A-Z]{1,4}[TCW56]
431 )
432 |
433 IDLE
434 )
435 \)
436 $break
437 ##x) { #"emacs
438 0 $$tzo = &mkoff($1);
439 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
440 0 return 1;
441 } elsif ($$tr =~ s#^GMT\s*([-+]\d{1,2})($break)##x) {
442 0 $o = $1;
443 0 ▶ if ($o < 24 and $o !~ /^0/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($o < 24 and not $o =~ /^0/) 0 0 0
Condition0%0/3
$o < 24 and not $o =~ /^0/
!ll&&!rl&&r
000
MC/DC0%0/2
$o < 24 and not $o =~ /^0/
$o < 24 not $o =~ /^0/
Truth table0%0/3
A and not(B)
A= $o < 24B= not $o =~ /^0/
ABresult
0X0
100
111
444 # probably hours.
445 0 ▶ printf "adjusted at %d. ($o 00)\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
446 0 $o = "${o}00";
447 }
448 0 $o =~ s/\b(\d\d\d)/0$1/;
449 0 $$tzo = &mkoff($o);
450 0 ▶ printf "matched at %d. ($$tzo, $o)\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
451 0 return 1;
452 } elsif ($$tr =~ s#^(?:GMT\s*)?([-+]\d\d:?\d\d)($break)##x) {
453 0 $o = $1;
454 0 $$tzo = &mkoff($o);
455 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
456 0 return 1;
457 } elsif ($$tr =~ s#^"?((?:[A-Z]{1,4}[TCW56])|IDLE)$break##x) { #"
458 0 $$tz = $1;
459 0 ▶ $$tz .= " DST"
Branch: 1 branch
BranchTrueFalseTotal
if $$tz eq "MET" and $$tr =~ s/^DST$break//x 0 0 0
Condition0%0/3
$$tz eq "MET" and $$tr =~ s/^DST$break//x
!ll&&!rl&&r
000
MC/DC0%0/2
$$tz eq "MET" and $$tr =~ s/^DST$break//x
$$tz eq "MET" $$tr =~ s/^DST$break//x
Truth table0%0/3
A and B
A= $$tz eq "MET"B= $$tr =~ s/^DST$break//x
ABresult
0X0
100
111
460 if $$tz eq 'MET' && $$tr =~ s#^DST$break##x;
461 0 ▶ printf "matched at %d: '$$tz'.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
462 0 return 1;
463 }
464 14 return 0;
465 }
466  
467 sub parse_date_only
468 14 ▶{
Subroutine parse_date_only: called CC=55 SCAR=76.9
Pod undocumented
469 14 my ($tr, $yr, $mr, $dr, $uk) = @_;
470  
471 14 $$tr =~ s#^\s+##;
472  
473 14 ▶ if ($$tr =~ s#^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(T|$break)##) {
Branch: 11 branches
BranchTrueFalseTotal
if ($$tr =~ s[^(\d\d\d\d)([-./])(\d\d?)\2(\d\d?)(T|$break)][]) { } 8 6 14
elsif ($$tr =~ s[^(\d\d?)([-./])(\d\d?)\2(\d\d\d\d?)($break)][]) { } 0 6 6
elsif ($$tr =~ s[^(\d\d\d\d)/(\d\d?)$break][]x) { } 0 6 6
elsif ($$tr =~ s[^(?xi) (?: (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday| Thu|Thursday|Fri|Friday| Sat|Saturday|Sun|Sunday),? \s+ )? (\d\d?) (\s+ | - | \. | /) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.? (?: \2 (\d\d (?:\d\d)? ) )? $break ][]) { } 0 6 6
elsif ($$tr =~ s[^(?xi) (?: (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday| Thu|Thursday|Fri|Friday| Sat|Saturday|Sun|Sunday),? \s+ )? (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.? ((\s)+ | - | \. | /) (\d\d?) ,? (?: (?: \2|\3+) (\d\d (?: \d\d)?) )? $break ][]) { } 6 0 6
elsif ($$tr =~ s/^(?xi) (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May| June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?| October|Oct\.?|November|Nov\.?|December|Dec\.?) \s+ (\d+) (?:st|nd|rd|th)? \,? (?: \s+ (?: (\d\d\d\d) |(?:\' (\d\d)) ) )? $break //) { } 0 0 0
elsif ($$tr =~ s[^(\d\d?)([-/.])(\d\d?)\2(\d\d?)($break)][]x) { } 0 0 0
elsif ($$tr =~ s[^(\d\d?)/(\d\d?)($break)][]x) { } 0 0 0
elsif ($$tr =~ s/^(\d\d)(\d\d)(\d\d)($break)//x) { } 0 0 0
elsif ($$tr =~ s[^(?xi) (\d{1,2}) (\s+ | - | \. | /) (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May| June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?| October|Oct\.?|November|Nov\.?|December|Dec\.?) (?: \2 ( \d\d (?:\d\d)? ) ) $break ][]) { } 0 0 0
elsif ($$tr =~ s/^(?xi) (\d+) (?:st|nd|rd|th)? \s+ (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May| June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?| October|Oct\.?|November|Nov\.?|December|Dec\.?) (?: \,? \s+ (\d\d\d\d) )? $break //) { } 0 0 0
474 # yyyy/mm/dd
475  
476 8 ($$yr, $$mr, $$dr) = ($1, $3, $4);
477 8 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 8 8
478 8 return 1;
479 } elsif ($$tr =~ s#^(\d\d?)([-./])(\d\d?)\2(\d\d\d\d?)($break)##) {
480 # mm/dd/yyyy - is this safe? No.
481 # -- or dd/mm/yyyy! If $1>12, then it's unambiguous.
482 # Otherwise check option UK for UK style date.
483 0 ▶ if ($uk || $1>12) {
Branch: 1 branch
BranchTrueFalseTotal
if ($uk or $1 > 12) { } 0 0 0
Condition0%0/3
$uk or $1 > 12
l!l&&r!l&&!r
000
MC/DC0%0/2
$uk or $1 > 12
$uk $1 > 12
Truth table0%0/3
A or B
A= $ukB= $1 > 12
ABresult
1X1
011
000
484 0 ($$yr, $$mr, $$dr) = ($4, $3, $1);
485 } else {
486 0 ($$yr, $$mr, $$dr) = ($4, $1, $3);
487 }
488 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
489 0 return 1;
490 } elsif ($$tr =~ s#^(\d\d\d\d)/(\d\d?)$break##x) {
491 # yyyy/mm
492  
493 0 ($$yr, $$mr, $$dr) = ($1, $2, 1);
494 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
495 0 return 1;
496 } elsif ($$tr =~ s#^(?xi)
497 (?:
498 (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday|
499 Thu|Thursday|Fri|Friday|
500 Sat|Saturday|Sun|Sunday),?
501 \s+
502 )?
503 (\d\d?)
504 (\s+ | - | \. | /)
505 (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.?
506 (?:
507 \2
508 (\d\d (?:\d\d)? )
509 )?
510 $break
511 ##) {
512 # [Dow,] dd Mon [yy[yy]]
513 0 ($$yr, $$mr, $$dr) = ($4, $mtable{"\u\L$3"}, $1);
514  
515 0 ▶ printf "%d: %s - %s - %s\n", __LINE__, $1, $2, $3 if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
516 0 ▶ print "y undef\n" if ($debug && ! defined($$yr));
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug and not defined $$yr 0 0 0
Condition0%0/3
$Time::ParseDate::debug and not defined $$yr
!ll&&!rl&&r
000
MC/DC0%0/2
$Time::ParseDate::debug and not defined $$yr
$Time::ParseDate::debug not defined $$yr
Truth table0%0/3
A and not(B)
A= $Time::ParseDate::debugB= not defined $$yr
ABresult
0X0
100
111
517 0 return 1;
518 } elsif ($$tr =~ s#^(?xi)
519 (?:
520 (?:Mon|Monday|Tue|Tuesday|Wed|Wednesday|
521 Thu|Thursday|Fri|Friday|
522 Sat|Saturday|Sun|Sunday),?
523 \s+
524 )?
525 (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.?
526 ((\s)+ | - | \. | /)
527
528 (\d\d?)
529 ,?
530 (?:
531 (?: \2|\3+)
532 (\d\d (?: \d\d)?)
533 )?
534 $break
535 ##) {
536 # [Dow,] Mon dd [yyyy]
537 # [Dow,] Mon d, [yy]
538 6 ($$yr, $$mr, $$dr) = ($5, $mtable{"\u\L$1"}, $4);
539 6 ▶ printf "%d: %s - %s - %s\n", __LINE__, $1, $2, $4 if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 6 6
540 6 ▶ print "y undef\n" if ($debug && ! defined($$yr));
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug and not defined $$yr 0 6 6
Condition33%1/3
$Time::ParseDate::debug and not defined $$yr
!ll&&!rl&&r
600
MC/DC0%0/2
$Time::ParseDate::debug and not defined $$yr
$Time::ParseDate::debug not defined $$yr
Truth table33%1/3
A and not(B)
A= $Time::ParseDate::debugB= not defined $$yr
ABresult
0X0
100
111
541 6 return 1;
542 } elsif ($$tr =~ s#^(?xi)
543 (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May|
544 June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?|
545 October|Oct\.?|November|Nov\.?|December|Dec\.?)
546 \s+
547 (\d+)
548 (?:st|nd|rd|th)?
549 \,?
550 (?:
551 \s+
552 (?:
553 (\d\d\d\d)
554 |(?:\' (\d\d))
555 )
556 )?
557 $break
558 ##) {
559 # Month day{st,nd,rd,th}, 'yy
560 # Month day{st,nd,rd,th}, year
561 # Month day, year
562 # Mon. day, year
563 0 ▶ ($$yr, $$mr, $$dr) = ($3 || $4, $mtable{"\u\L$1"}, $2);
Condition0%0/3
$3 || $4
l!l&&r!l&&!r
000
MC/DC0%0/2
$3 || $4
$3 $4
Truth table0%0/3
A || B
A= $3B= $4
ABresult
1X1
011
000
564 0 ▶ printf "%d: %s - %s - %s - %s\n", __LINE__, $1, $2, $3, $4 if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
565 0 ▶ print "y undef\n" if ($debug && ! defined($$yr));
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug and not defined $$yr 0 0 0
Condition0%0/3
$Time::ParseDate::debug and not defined $$yr
!ll&&!rl&&r
000
MC/DC0%0/2
$Time::ParseDate::debug and not defined $$yr
$Time::ParseDate::debug not defined $$yr
Truth table0%0/3
A and not(B)
A= $Time::ParseDate::debugB= not defined $$yr
ABresult
0X0
100
111
566 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
567 0 return 1;
568 } elsif ($$tr =~ s#^(\d\d?)([-/.])(\d\d?)\2(\d\d?)($break)##x) {
569 0 ▶ if ($1 > 31 || (!$uk && $1 > 12 && $4 < 32)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 > 31 or not $uk and $1 > 12 and $4 < 32) { } 0 0 0
elsif ($1 > 12 or $uk) { } 0 0 0
Condition0%0/9
$1 > 31 or not $uk and $1 > 12 and $4 < 32
l!l&&r!l&&!r
000
not $uk and $1 > 12 and $4 < 32
!ll&&!rl&&r
000
not $uk and $1 > 12
!ll&&!rl&&r
000
MC/DC0%0/4
$1 > 31 or not $uk and $1 > 12 and $4 < 32
$1 > 31 not $uk $1 > 12 $4 < 32
Truth table0%0/5
A or not(B) and C and D
A= $1 > 31B= not $ukC= $1 > 12D= $4 < 32
ABCDresult
1XXX1
01111
00XX0
010X0
01100
570 # yy/mm/dd
571 0 ($$yr, $$mr, $$dr) = ($1, $3, $4);
572 ▶ } elsif ($1 > 12 || $uk) {
Condition0%0/3
$1 > 12 or $uk
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 > 12 or $uk
$1 > 12 $uk
Truth table0%0/3
A or B
A= $1 > 12B= $uk
ABresult
1X1
011
000
573 # dd/mm/yy
574 0 ($$yr, $$mr, $$dr) = ($4, $3, $1);
575 } else {
576 # mm/dd/yy
577 0 ($$yr, $$mr, $$dr) = ($4, $1, $3);
578 }
579 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
580 0 return 1;
581 } elsif ($$tr =~ s#^(\d\d?)/(\d\d?)($break)##x) {
582 0 ▶ if ($1 > 31 || (!$uk && $1 > 12)) {
Branch: 3 branches
BranchTrueFalseTotal
if ($1 > 31 or not $uk and $1 > 12) { } 0 0 0
elsif ($2 > 31 or $uk and $2 > 12) { } 0 0 0
elsif ($1 > 12 or $uk) { } 0 0 0
Condition0%0/6
$1 > 31 or not $uk and $1 > 12
l!l&&r!l&&!r
000
not $uk and $1 > 12
!ll&&!rl&&r
000
MC/DC0%0/3
$1 > 31 or not $uk and $1 > 12
$1 > 31 not $uk $1 > 12
Truth table0%0/4
A or not(B) and C
A= $1 > 31B= not $ukC= $1 > 12
ABCresult
1XX1
0111
00X0
0100
583 # yy/mm
584 0 ($$yr, $$mr, $$dr) = ($1, $2, 1);
585 ▶ } elsif ($2 > 31 || ($uk && $2 > 12)) {
Condition0%0/6
$2 > 31 or $uk and $2 > 12
l!l&&r!l&&!r
000
$uk and $2 > 12
!ll&&!rl&&r
000
MC/DC0%0/3
$2 > 31 or $uk and $2 > 12
$2 > 31 $uk $2 > 12
Truth table0%0/4
A or B and C
A= $2 > 31B= $ukC= $2 > 12
ABCresult
1XX1
0111
00X0
0100
586 # mm/yy
587 0 ($$yr, $$mr, $$dr) = ($2, $1, 1);
588 ▶ } elsif ($1 > 12 || $uk) {
Condition0%0/3
$1 > 12 or $uk
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 > 12 or $uk
$1 > 12 $uk
Truth table0%0/3
A or B
A= $1 > 12B= $uk
ABresult
1X1
011
000
589 # dd/mm
590 0 ($$mr, $$dr) = ($2, $1);
591 } else {
592 # mm/dd
593 0 ($$mr, $$dr) = ($1, $2);
594 }
595 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
596 0 return 1;
597 } elsif ($$tr =~ s#^(\d\d)(\d\d)(\d\d)($break)##x) {
598 0 ▶ if ($1 > 31 || (!$uk && $1 > 12)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 > 31 or not $uk and $1 > 12) { } 0 0 0
elsif ($1 > 12 or $uk) { } 0 0 0
Condition0%0/6
$1 > 31 or not $uk and $1 > 12
l!l&&r!l&&!r
000
not $uk and $1 > 12
!ll&&!rl&&r
000
MC/DC0%0/3
$1 > 31 or not $uk and $1 > 12
$1 > 31 not $uk $1 > 12
Truth table0%0/4
A or not(B) and C
A= $1 > 31B= not $ukC= $1 > 12
ABCresult
1XX1
0111
00X0
0100
599 # YYMMDD
600 0 ($$yr, $$mr, $$dr) = ($1, $2, $3);
601 ▶ } elsif ($1 > 12 || $uk) {
Condition0%0/3
$1 > 12 or $uk
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 > 12 or $uk
$1 > 12 $uk
Truth table0%0/3
A or B
A= $1 > 12B= $uk
ABresult
1X1
011
000
602 # DDMMYY
603 0 ($$yr, $$mr, $$dr) = ($3, $2, $1);
604 } else {
605 # MMDDYY
606 0 ($$yr, $$mr, $$dr) = ($3, $1, $2);
607 }
608 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
609 0 return 1;
610 } elsif ($$tr =~ s#^(?xi)
611 (\d{1,2})
612 (\s+ | - | \. | /)
613 (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May|
614 June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?|
615 October|Oct\.?|November|Nov\.?|December|Dec\.?)
616 (?:
617 \2
618 (
619 \d\d
620 (?:\d\d)?
621 )
622 )
623 $break
624 ##) {
625 # dd Month [yr]
626 0 ($$yr, $$mr, $$dr) = ($4, $mtable{"\u\L$3"}, $1);
627 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
628 0 return 1;
629 } elsif ($$tr =~ s#^(?xi)
630 (\d+)
631 (?:st|nd|rd|th)?
632 \s+
633 (January|Jan\.?|February|Feb\.?|March|Mar\.?|April|Apr\.?|May|
634 June|Jun\.?|July|Jul\.?|August|Aug\.?|September|Sep\.?|
635 October|Oct\.?|November|Nov\.?|December|Dec\.?)
636 (?:
637 \,?
638 \s+
639 (\d\d\d\d)
640 )?
641 $break
642 ##) {
643 # day{st,nd,rd,th}, Month year
644 0 ($$yr, $$mr, $$dr) = ($3, $mtable{"\u\L$2"}, $1);
645 0 ▶ printf "%d: %s - %s - %s - %s\n", __LINE__, $1, $2, $3, $4 if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
646 0 ▶ print "y undef\n" if ($debug && ! defined($$yr));
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug and not defined $$yr 0 0 0
Condition0%0/3
$Time::ParseDate::debug and not defined $$yr
!ll&&!rl&&r
000
MC/DC0%0/2
$Time::ParseDate::debug and not defined $$yr
$Time::ParseDate::debug not defined $$yr
Truth table0%0/3
A and not(B)
A= $Time::ParseDate::debugB= not defined $$yr
ABresult
0X0
100
111
647 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
648 0 return 1;
649 }
650 0 return 0;
651 }
652  
653 sub parse_time_only
654 14 ▶{
Subroutine parse_time_only: called CC=31 SCAR=53.0
Pod undocumented
655 14 my ($tr, $hr, $mr, $sr, $tzr, %options) = @_;
656  
657 14 $$tr =~ s#^\s+##;
658  
659 14 ▶ if ($$tr =~ s/^(?x)
Branch: 3 branches
BranchTrueFalseTotal
if ($$tr =~ s/^(?x) (?: (?: ([012]\d) (?# $1) (?: ([0-5]\d) (?# $2) (?: ([0-5]\d) (?# $3) )? ) (?:\s*([apAP][mM]))? (?# $4) ) | (?: (\d{1,2}) (?# $5) (?: \: (\d\d) (?# $6) (?: \: (\d\d) (?# $7) ( (?# don't barf on database sub-second timings) [:.,] \d+ )? (?# $8) )? ) (?:\s*([apAP][mM]))? (?# $9) ) | (?: (\d{1,2}) (?# $10) ([apAP][mM]) (?# ${11}) ) ) (?: (?: \s+ "? ( (?# ${12}) (?: [A-Z]{1,4}[TCW56](?!(?:\+\d+|\s+DST)) ) | IDLE ) ) | ([Zz]) (?# ${13}) )? $break //) { } 6 8 14
elsif ($$tr =~ s/^noon$break//xi) { } 0 8 8
elsif ($$tr =~ s/^midnight$break//xi) { } 0 8 8
660 (?:
661 (?:
662 ([012]\d) (?# $1)
663 (?:
664 ([0-5]\d) (?# $2)
665 (?:
666 ([0-5]\d) (?# $3)
667 )?
668 )
669 (?:\s*([apAP][mM]))? (?# $4)
670 ) | (?:
671 (\d{1,2}) (?# $5)
672 (?:
673 \:
674 (\d\d) (?# $6)
675 (?:
676 \:
677 (\d\d) (?# $7)
678 (
679 (?# don't barf on database sub-second timings)
680 [:.,]
681 \d+
682 )? (?# $8)
683 )?
684 )
685 (?:\s*([apAP][mM]))? (?# $9)
686 ) | (?:
687 (\d{1,2}) (?# $10)
688 ([apAP][mM]) (?# ${11})
689 )
690 )
691 (?:
692 (?:
693 \s+
694 "?
695 ( (?# ${12})
696 (?: [A-Z]{1,4}[TCW56](?!(?:\+\d+|\s+DST)) )
697 |
698 IDLE
699 )
700 )
701 |
702 ([Zz]) (?# ${13})
703 )?
704 $break
705 //) { #"emacs
706 # HH[[:]MM[:SS]]meridian [zone]
707 6 my $ampm;
708 6 ▶ $$hr = $1 || $5 || $10 || 0; # 10 is undef, but 5 is defined..
Condition37%3/8
$1 || $5 || $10 || 0
l!l
60
$1 or $5 or $10
l!l&&r!l&&!r
600
$1 or $5
l!l&&r!l&&!r
060
MC/DC0%0/3
$1 || $5 || $10 || 0
$1 $5 $10
Truth table25%1/4
A or B or C
A= $1B= $5C= $10
ABCresult
1XX1
01X1
0011
0000
709 6 ▶ $$mr = $2 || $6 || 0;
Condition40%2/5
$2 || $6 || 0
l!l
60
$2 or $6
l!l&&r!l&&!r
060
MC/DC0%0/2
$2 || $6 || 0
$2 $6
Truth table33%1/3
A or B
A= $2B= $6
ABresult
1X1
011
000
710 6 ▶ $$sr = $3 || $7 || 0;
Condition40%2/5
$3 || $7 || 0
l!l
60
$3 or $7
l!l&&r!l&&!r
060
MC/DC0%0/2
$3 || $7 || 0
$3 $7
Truth table33%1/3
A or B
A= $3B= $7
ABresult
1X1
011
000
711 6 ▶ if (defined($8) && exists($options{SUBSECOND}) && $options{SUBSECOND}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $8 and exists $options{"SUBSECOND"} and $options{"SUBSECOND"}) 0 6 6
Condition33%2/6
defined $8 and exists $options{"SUBSECOND"} and $options{"SUBSECOND"}
!ll&&!rl&&r
600
defined $8 and exists $options{"SUBSECOND"}
!ll&&!rl&&r
600
MC/DC0%0/3
defined $8 and exists $options{"SUBSECOND"} and $options{"SUBSECOND"}
defined $8 exists $options{"SUBSECOND"} $options{"SUBSECOND"}
Truth table25%1/4
A and B and C
A= defined $8B= exists $options{"SUBSECOND"}C= $options{"SUBSECOND"}
ABCresult
0XX0
10X0
1100
1111
712 0 my($frac) = $8;
713 0 substr($frac,0,1) = '.';
714 0 $$sr += $frac;
715 }
716 6 ▶ print "S = $$sr\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 6 6
717 6 ▶ $ampm = $4 || $9 || $11 || '';
Condition37%3/8
$4 || $9 || $11 || ''
l!l
06
$4 or $9 or $11
l!l&&r!l&&!r
006
$4 or $9
l!l&&r!l&&!r
006
MC/DC0%0/3
$4 || $9 || $11 || ''
$4 $9 $11
Truth table25%1/4
A or B or C
A= $4B= $9C= $11
ABCresult
1XX1
01X1
0011
0000
718 6 ▶ printf "ampm at %d: %s %s %s\n", __LINE__, $4||'(no)', $9||'(no)', $11||'(no)' if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 6 6
Condition0%0/6
$4 || '(no)'
l!l
00
$9 || '(no)'
l!l
00
$11 || '(no)'
l!l
00
MC/DC0%0/1
$4 || '(no)'
$4
MC/DC0%0/1
$9 || '(no)'
$9
MC/DC0%0/1
$11 || '(no)'
$11
Truth table0%0/2
A
A= $4
Aresult
11
00
Truth table0%0/2
A
A= $9
Aresult
11
00
Truth table0%0/2
A
A= $11
Aresult
11
00
719 6 $$tzr = $12;
720 6 ▶ $$tzr = 'UTC' if defined $13;
Branch: 1 branch
BranchTrueFalseTotal
if defined $13 0 6 6
721 6 ▶ $$hr += 12 if $ampm and "\U$ampm" eq "PM" && $$hr != 12;
Branch: 1 branch
BranchTrueFalseTotal
if $ampm and (uc $ampm eq "PM" and $$hr != 12) 0 6 6
Condition16%1/6
$ampm and (uc $ampm eq "PM" and $$hr != 12)
!ll&&!rl&&r
600
uc $ampm eq "PM" and $$hr != 12
!ll&&!rl&&r
000
MC/DC0%0/3
$ampm and (uc $ampm eq "PM" and $$hr != 12)
$ampm uc $ampm eq "PM" $$hr != 12
Truth table25%1/4
A and B and C
A= $ampmB= uc $ampm eq "PM"C= $$hr != 12
ABCresult
0XX0
10X0
1100
1111
722 6 ▶ $$hr = 0 if $$hr == 12 && "\U$ampm" eq "AM";
Branch: 1 branch
BranchTrueFalseTotal
if $$hr == 12 and uc $ampm eq "AM" 0 6 6
Condition33%1/3
$$hr == 12 and uc $ampm eq "AM"
!ll&&!rl&&r
600
MC/DC0%0/2
$$hr == 12 and uc $ampm eq "AM"
$$hr == 12 uc $ampm eq "AM"
Truth table33%1/3
A and B
A= $$hr == 12B= uc $ampm eq "AM"
ABresult
0X0
100
111
723 6 ▶ printf "matched at %d, rem = %s.\n", __LINE__, $$tr if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 6 6
724 6 return 1;
725 } elsif ($$tr =~ s#^noon$break##ix) {
726 # noon
727 0 ($$hr, $$mr, $$sr) = (12, 0, 0);
728 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
729 0 return 1;
730 } elsif ($$tr =~ s#^midnight$break##ix) {
731 # midnight
732 0 ($$hr, $$mr, $$sr) = (0, 0, 0);
733 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
734 0 return 1;
735 }
736 8 return 0;
737 }
738  
739 sub parse_time_offset
740 8 ▶{
Subroutine parse_time_offset: called CC=11 SCAR=42.9
Pod undocumented
741 8 my ($tr, $rsr, %options) = @_;
742  
743 8 $$tr =~ s/^\s+//;
744  
745 8 ▶ return 0 if $options{NO_RELATIVE};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"NO_RELATIVE"} 0 8 8
746  
747 8 ▶ if ($$tr =~ s{^(?xi)
Branch: 1 branch
BranchTrueFalseTotal
if ($$tr =~ s[^(?xi) (?: (-) (?# 1) | [+] )? \s* (?: (\d+(?:\.\d+)?) (?# 2) | (?:(\d+)\s+(\d+)/(\d+)) (?# 3 4/5) ) \s* (sec|second|min|minute|hour)s? (?# 6) ( \s+ ago (?# 7) )? $break ][]) 0 8 8
748 (?:
749 (-) (?# 1)
750 |
751 [+]
752 )?
753 \s*
754 (?:
755 (\d+(?:\.\d+)?) (?# 2)
756 |
757 (?:(\d+)\s+(\d+)/(\d+)) (?# 3 4/5)
758 )
759 \s*
760 (sec|second|min|minute|hour)s? (?# 6)
761 (
762 \s+
763 ago (?# 7)
764 )?
765 $break
766 }{}) {
767 # count units
768 0 ▶ $$rsr = 0 unless defined $$rsr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$rsr 0 0 0
769 0 ▶ return 0 if defined($5) && $5 == 0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $5 and $5 == 0 0 0 0
Condition0%0/3
defined $5 and $5 == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $5 and $5 == 0
defined $5 $5 == 0
Truth table0%0/3
A and B
A= defined $5B= $5 == 0
ABresult
0X0
100
111
770 0 ▶ my $num = defined($2)
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 0 0 0
771 ? $2
772 : $3 + $4/$5;
773 0 ▶ $num = -$num if $1;
Branch: 1 branch
BranchTrueFalseTotal
if $1 0 0 0
774 0 $$rsr += $umult{"\L$6"} * $num;
775  
776 0 ▶ $$rsr = -$$rsr if $7 ||
Branch: 1 branch
BranchTrueFalseTotal
if $7 or $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/ 0 0 0
Condition0%0/3
$7 or $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
$7 or $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/
$7 $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/
Truth table0%0/3
A or B
A= $7B= $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/
ABresult
1X1
011
000
777 $$tr =~ /\b(day|mon|month|year)s?\s*ago\b/;
778 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
779 0 return 1;
780 }
781 8 return 0;
782 }
783  
784 #
785 # What to you do with a date that has a two-digit year?
786 # There's not much that can be done except make a guess.
787 #
788 # Some example situations to handle:
789 #
790 # now year
791 #
792 # 1999 01
793 # 1999 71
794 # 2010 71
795 # 2110 09
796 #
797  
798 sub expand_two_digit_year
799 0 ▶{
Subroutine expand_two_digit_year: not called CC=12 SCAR=50.5
Pod undocumented
800 0 my ($yr, $now, %options) = @_;
801  
802 0 ▶ return $yr if $yr > 100;
Branch: 1 branch
BranchTrueFalseTotal
if $yr > 100 0 0 0
803  
804 0 my ($y) = (&righttime($now, %options))[5];
805 0 $y += 1900;
806 0 my $century = int($y / 100) * 100;
807 0 my $within = $y % 100;
808  
809 0 my $r = $yr + $century;
810  
811 0 ▶ if ($options{PREFER_PAST}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($options{'PREFER_PAST'}) { } 0 0 0
elsif ($options{'PREFER_FUTURE'}) { } 0 0 0
elsif ($options{'UNAMBIGUOUS'}) { } 0 0 0
812 0 ▶ if ($yr > $within) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yr > $within) 0 0 0
813 0 $r = $yr + $century - 100;
814 }
815 } elsif ($options{PREFER_FUTURE}) {
816 # being strict here would be silly
817 0 ▶ if ($yr < $within-20) {
Branch: 1 branch
BranchTrueFalseTotal
if ($yr < $within - 20) 0 0 0
818 # it's 2019 and the date is '08'
819 0 $r = $yr + $century + 100;
820 }
821 } elsif ($options{UNAMBIGUOUS}) {
822 # we really shouldn't guess
823 0 return undef;
824 } else {
825 # prefer the current century in most cases
826  
827 0 ▶ if ($within > 80 && $within - $yr > 60) {
Branch: 1 branch
BranchTrueFalseTotal
if ($within > 80 and $within - $yr > 60) 0 0 0
Condition0%0/3
$within > 80 and $within - $yr > 60
!ll&&!rl&&r
000
MC/DC0%0/2
$within > 80 and $within - $yr > 60
$within > 80 $within - $yr > 60
Truth table0%0/3
A and B
A= $within > 80B= $within - $yr > 60
ABresult
0X0
100
111
828 0 $r = $yr + $century + 100;
829 }
830  
831 0 ▶ if ($within < 30 && $yr - $within > 59) {
Branch: 1 branch
BranchTrueFalseTotal
if ($within < 30 and $yr - $within > 59) 0 0 0
Condition0%0/3
$within < 30 and $yr - $within > 59
!ll&&!rl&&r
000
MC/DC0%0/2
$within < 30 and $yr - $within > 59
$within < 30 $yr - $within > 59
Truth table0%0/3
A and B
A= $within < 30B= $yr - $within > 59
ABresult
0X0
100
111
832 0 $r = $yr + $century - 100;
833 }
834 }
835 0 ▶ print "two digit year '$yr' expanded into $r\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
836 0 return $r;
837 }
838  
839  
840 sub calc
841 0 ▶{
Subroutine calc: not called CC=12 SCAR=50.5
Pod undocumented
842 0 my ($rsr, $yr, $mr, $dr, $rdr, $now, $units, $count, %options) = @_;
843  
844 0 ▶ confess unless $units;
Branch: 1 branch
BranchTrueFalseTotal
unless $units 0 0 0
845 0 $units = "\L$units";
846 0 ▶ print "calc based on $units\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
847  
848 0 ▶ if ($units eq 'day') {
Branch: 5 branches
BranchTrueFalseTotal
if ($units eq 'day') { } 0 0 0
elsif ($units eq 'week') { } 0 0 0
elsif ($umult{$units}) { } 0 0 0
elsif ($units eq 'mon' or $units eq 'month') { } 0 0 0
elsif ($units eq 'year') { } 0 0 0
849 0 $$rdr = $count;
850 } elsif ($units eq 'week') {
851 0 $$rdr = $count * 7;
852 } elsif ($umult{$units}) {
853 0 $$rsr = $count * $umult{$units};
854 ▶ } elsif ($units eq 'mon' || $units eq 'month') {
Condition0%0/3
$units eq "mon" or $units eq "month"
l!l&&r!l&&!r
000
MC/DC0%0/2
$units eq "mon" or $units eq "month"
$units eq "mon" $units eq "month"
Truth table0%0/3
A or B
A= $units eq "mon"B= $units eq "month"
ABresult
1X1
011
000
855 0 ($$yr, $$mr, $$dr) = &monthoff($now, $count, %options);
856 0 ▶ $$rsr = 0 unless $$rsr;
Branch: 1 branch
BranchTrueFalseTotal
unless $$rsr 0 0 0
857 } elsif ($units eq 'year') {
858 0 ($$yr, $$mr, $$dr) = &monthoff($now, $count * 12, %options);
859 0 ▶ $$rsr = 0 unless $$rsr;
Branch: 1 branch
BranchTrueFalseTotal
unless $$rsr 0 0 0
860 } else {
861 0 carp "interal error";
862 }
863 0 ▶ print "calced rsr $$rsr rdr $$rdr, yr $$yr mr $$mr dr $$dr.\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
864 }
865  
866 sub monthoff
867 0 ▶{
Subroutine monthoff: not called CC=13 SCAR=50.3
Pod undocumented
868 0 my ($now, $months, %options) = @_;
869  
870 # months are 0..11
871 0 my ($d, $m11, $y) = (&righttime($now, %options)) [ 3,4,5 ] ;
872  
873 0 $y += 1900;
874  
875 0 ▶ print "m11 = $m11 + $months, y = $y\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
876  
877 0 $m11 += $months;
878  
879 0 ▶ print "m11 = $m11, y = $y\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
880 0 ▶ if ($m11 > 11 || $m11 < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($m11 > 11 or $m11 < 0) 0 0 0
Condition0%0/3
$m11 > 11 or $m11 < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
$m11 > 11 or $m11 < 0
$m11 > 11 $m11 < 0
Truth table0%0/3
A or B
A= $m11 > 11B= $m11 < 0
ABresult
1X1
011
000
881 0 ▶ $y -= 1 if $m11 < 0 && ($m11 % 12 != 0);
Branch: 1 branch
BranchTrueFalseTotal
if $m11 < 0 and $m11 % 12 != 0 0 0 0
Condition0%0/3
$m11 < 0 and $m11 % 12 != 0
!ll&&!rl&&r
000
MC/DC0%0/2
$m11 < 0 and $m11 % 12 != 0
$m11 < 0 $m11 % 12 != 0
Truth table0%0/3
A and B
A= $m11 < 0B= $m11 % 12 != 0
ABresult
0X0
100
111
882 0 $y += int($m11/12);
883  
884 # this is required to work around a bug in perl 5.003
885 5 ▶ no integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
886 0 $m11 %= 12;
887 }
888 0 ▶ print "m11 = $m11, y = $y\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
889  
890 #
891 # What is "1 month from January 31st?"
892 # I think the answer is February 28th most years.
893 #
894 # Similarly, what is one year from February 29th, 1980?
895 # I think it's February 28th, 1981.
896 #
897 # If you disagree, change the following code.
898 #
899 0 ▶ if ($d > 30 or ($d > 28 && $m11 == 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d > 30 or $d > 28 and $m11 == 1) 0 0 0
Condition0%0/6
$d > 30 or $d > 28 and $m11 == 1
l!l&&r!l&&!r
000
$d > 28 and $m11 == 1
!ll&&!rl&&r
000
MC/DC0%0/3
$d > 30 or $d > 28 and $m11 == 1
$d > 30 $d > 28 $m11 == 1
Truth table0%0/4
A or B and C
A= $d > 30B= $d > 28C= $m11 == 1
ABCresult
1XX1
0111
00X0
0100
900 0 require Time::DaysInMonth;
901 0 my $dim = Time::DaysInMonth::days_in($y, $m11+1);
902 0 ▶ print "dim($y,$m11+1)= $dim\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
903 0 ▶ $d = $dim if $d > $dim;
Branch: 1 branch
BranchTrueFalseTotal
if $d > $dim 0 0 0
904 }
905 0 return ($y, $m11+1, $d);
906 }
907  
908 sub righttime
909 0 ▶{
Subroutine righttime: not called CC=2 SCAR=17.9
Pod undocumented
910 0 my ($time, %options) = @_;
911 0 ▶ if ($options{GMT}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'GMT'}) { } 0 0 0
912 0 return gmtime($time);
913 } else {
914 0 return localtime($time);
915 }
916 }
917  
918 sub parse_year_only
919 6 ▶{
Subroutine parse_year_only: called CC=5 SCAR=22.3
Pod undocumented
920 6 my ($tr, $yr, $now, %options) = @_;
921  
922 6 $$tr =~ s#^\s+##;
923  
924 6 ▶ if ($$tr =~ s#^(\d\d\d\d)$break##) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$tr =~ s/^(\d\d\d\d)$break//) { } 6 0 6
elsif ($$tr =~ s/\'(\d\d)$break//) { } 0 0 0
925 6 $$yr = $1;
926 6 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 6 6
927 6 return 1;
928 } elsif ($$tr =~ s#\'(\d\d)$break##) {
929 0 $$yr = expand_two_digit_year($1, $now, %options);
930 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
931 0 return 1;
932 }
933 0 return 0;
934 }
935  
936 sub parse_date_offset
937 0 ▶{
Subroutine parse_date_offset: not called CC=43 SCAR=75.5
Pod undocumented
938 0 my ($tr, $now, $yr, $mr, $dr, $rdr, $rsr, %options) = @_;
939  
940 0 ▶ return 0 if $options{NO_RELATIVE};
Branch: 1 branch
BranchTrueFalseTotal
if $options{"NO_RELATIVE"} 0 0 0
941  
942 # now - current seconds_since_epoch
943 # yr - year return
944 # mr - month return
945 # dr - day return
946 # rdr - relative day return
947 # rsr - relative second return
948  
949 0 my $j;
950 0 my $wday = (&righttime($now, %options))[6];
951  
952 0 $$tr =~ s#^\s+##;
953  
954 0 ▶ if ($$tr =~ s#^(?xi)
Branch: 14 branches
BranchTrueFalseTotal
if ($$tr =~ s/^(?xi) \s* (\d+) \s* (day|week|month|year)s? ( \s+ ago )? $break //) { } 0 0 0
elsif ($$tr =~ s/^(?xi) (?: (?: now \s+ )? (\+ | \-) \s* )? (\d+) \s* (day|week|month|year)s? $break //) { } 0 0 0
elsif ($$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) \s+ after \s+ next $break //) { } 0 0 0
elsif ($$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) \s+ before \s+ last $break //) { } 0 0 0
elsif ($$tr =~ s/^(?xi) next\s+ (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break //) { } 0 0 0
elsif ($$tr =~ s/^(?xi) last\s+ (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break//) { } 0 0 0
elsif ($options{'PREFER_PAST'} and $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break//) { } 0 0 0
elsif ($options{'PREFER_FUTURE'} and $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break //) { } 0 0 0
elsif ($$tr =~ s/^today$break//xi) { } 0 0 0
elsif ($$tr =~ s/^tomorrow$break//xi) { } 0 0 0
elsif ($$tr =~ s/^yesterday$break//xi) { } 0 0 0
elsif ($$tr =~ s/^last\s+(week|month|year)$break//xi) { } 0 0 0
elsif ($$tr =~ s/^next\s+(week|month|year)$break//xi) { } 0 0 0
elsif ($$tr =~ s/^now $break//x) { } 0 0 0
955 \s*
956 (\d+)
957 \s*
958 (day|week|month|year)s?
959 (
960 \s+
961 ago
962 )?
963 $break
964 ##) {
965 0 my $amt = $1 + 0;
966 0 my $units = $2;
967 0 ▶ $amt = -$amt if $3 ||
Branch: 1 branch
BranchTrueFalseTotal
if $3 or $$tr =~ /\b(sec|second|min|minute|hour)s?\s*ago\b/ 0 0 0
Condition0%0/3
$3 or $$tr =~ /\b(sec|second|min|minute|hour)s?\s*ago\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
$3 or $$tr =~ /\b(sec|second|min|minute|hour)s?\s*ago\b/
$3 $$tr =~ /\b(sec|second|min|minute|hour)s?\s*ago\b/
Truth table0%0/3
A or B
A= $3B= $$tr =~ /\b(sec|second|min|minute|hour)s?\s*ago\b/
ABresult
1X1
011
000
968 $$tr =~ m#\b(sec|second|min|minute|hour)s?\s*ago\b#;
969 0 &calc($rsr, $yr, $mr, $dr, $rdr, $now, $units,
970 $amt, %options);
971 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
972 0 return 1;
973 } elsif ($$tr =~ s#^(?xi)
974 (?:
975 (?:
976 now
977 \s+
978 )?
979 (\+ | \-)
980 \s*
981 )?
982 (\d+)
983 \s*
984 (day|week|month|year)s?
985 $break
986 ##) {
987 0 ▶ my $one = $1 || '';
Condition0%0/2
$1 || ''
l!l
00
MC/DC0%0/1
$1 || ''
$1
Truth table0%0/2
A
A= $1
Aresult
11
00
988 0 ▶ my $two = $2 || '';
Condition0%0/2
$2 || ''
l!l
00
MC/DC0%0/1
$2 || ''
$2
Truth table0%0/2
A
A= $2
Aresult
11
00
989 0 my $amt = "$one$two"+0;
990 0 &calc($rsr, $yr, $mr, $dr, $rdr, $now, $3,
991 $amt, %options);
992 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
993 0 return 1;
994 } elsif ($$tr =~ s#^(?xi)
995 (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
996 |Wednesday|Thursday|Friday|Saturday|Sunday)
997 \s+
998 after
999 \s+
1000 next
1001 $break
1002 ##) {
1003 # Dow "after next"
1004 0 ▶ $$rdr = $wdays{"\L$1"} - $wday + ( $wdays{"\L$1"} > $wday ? 7 : 14);
Branch: 1 branch
BranchTrueFalseTotal
$wdays{lc $1} > $wday ? : 0 0 0
1005 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1006 0 return 1;
1007 } elsif ($$tr =~ s#^(?xi)
1008 (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
1009 |Wednesday|Thursday|Friday|Saturday|Sunday)
1010 \s+
1011 before
1012 \s+
1013 last
1014 $break
1015 ##) {
1016 # Dow "before last"
1017 0 ▶ $$rdr = $wdays{"\L$1"} - $wday - ( $wdays{"\L$1"} < $wday ? 7 : 14);
Branch: 1 branch
BranchTrueFalseTotal
$wdays{lc $1} < $wday ? : 0 0 0
1018 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1019 0 return 1;
1020 } elsif ($$tr =~ s#^(?xi)
1021 next\s+
1022 (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
1023 |Wednesday|Thursday|Friday|Saturday|Sunday)
1024 $break
1025 ##) {
1026 # "next" Dow
1027 $$rdr = $wdays{"\L$1"} - $wday
1028 0 ▶ + ( $wdays{"\L$1"} > $wday ? 0 : 7);
Branch: 1 branch
BranchTrueFalseTotal
$wdays{lc $1} > $wday ? : 0 0 0
1029 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1030 0 return 1;
1031 } elsif ($$tr =~ s#^(?xi)
1032 last\s+
1033 (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
1034 |Wednesday|Thursday|Friday|Saturday|Sunday)
1035 $break##) {
1036 # "last" Dow
1037 0 ▶ printf "c %d - %d + ( %d < %d ? 0 : -7 \n", $wdays{"\L$1"}, $wday, $wdays{"\L$1"}, $wday if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1038 0 ▶ $$rdr = $wdays{"\L$1"} - $wday + ( $wdays{"\L$1"} < $wday ? 0 : -7);
Branch: 1 branch
BranchTrueFalseTotal
$wdays{lc $1} < $wday ? : 0 0 0
1039 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1040 0 return 1;
1041 ▶ } elsif ($options{PREFER_PAST} and $$tr =~ s#^(?xi)
Condition0%0/3
$options{"PREFER_PAST"} and $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break//
!ll&&!rl&&r
000
MC/DC0%0/2
$options{"PREFER_PAST"} and $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break//
$options{"PREFER_PAST"} $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break//
Truth table0%0/3
A and B
A= $options{"PREFER_PAST"}B= $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break//
ABresult
0X0
100
111
1042 (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
1043 |Wednesday|Thursday|Friday|Saturday|Sunday)
1044 $break##) {
1045 # Dow
1046 0 ▶ printf "c %d - %d + ( %d < %d ? 0 : -7 \n", $wdays{"\L$1"}, $wday, $wdays{"\L$1"}, $wday if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1047 0 ▶ $$rdr = $wdays{"\L$1"} - $wday + ( $wdays{"\L$1"} < $wday ? 0 : -7);
Branch: 1 branch
BranchTrueFalseTotal
$wdays{lc $1} < $wday ? : 0 0 0
1048 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1049 0 return 1;
1050 ▶ } elsif ($options{PREFER_FUTURE} and $$tr =~ s#^(?xi)
Condition0%0/3
$options{"PREFER_FUTURE"} and $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break //
!ll&&!rl&&r
000
MC/DC0%0/2
$options{"PREFER_FUTURE"} and $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break //
$options{"PREFER_FUTURE"} $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break //
Truth table0%0/3
A and B
A= $options{"PREFER_FUTURE"}B= $$tr =~ s/^(?xi) (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday |Wednesday|Thursday|Friday|Saturday|Sunday) $break //
ABresult
0X0
100
111
1051 (Mon|Tue|Wed|Thu|Fri|Sat|Sun|Monday|Tuesday
1052 |Wednesday|Thursday|Friday|Saturday|Sunday)
1053 $break
1054 ##) {
1055 # Dow
1056 $$rdr = $wdays{"\L$1"} - $wday
1057 0 ▶ + ( $wdays{"\L$1"} > $wday ? 0 : 7);
Branch: 1 branch
BranchTrueFalseTotal
$wdays{lc $1} > $wday ? : 0 0 0
1058 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1059 0 return 1;
1060 } elsif ($$tr =~ s#^today$break##xi) {
1061 # today
1062 0 $$rdr = 0;
1063 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1064 0 return 1;
1065 } elsif ($$tr =~ s#^tomorrow$break##xi) {
1066 0 $$rdr = 1;
1067 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1068 0 return 1;
1069 } elsif ($$tr =~ s#^yesterday$break##xi) {
1070 0 $$rdr = -1;
1071 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1072 0 return 1;
1073 } elsif ($$tr =~ s#^last\s+(week|month|year)$break##xi) {
1074 0 &calc($rsr, $yr, $mr, $dr, $rdr, $now, $1, -1, %options);
1075 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1076 0 return 1;
1077 } elsif ($$tr =~ s#^next\s+(week|month|year)$break##xi) {
1078 0 &calc($rsr, $yr, $mr, $dr, $rdr, $now, $1, 1, %options);
1079 0 ▶ printf "matched at %d.\n", __LINE__ if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $Time::ParseDate::debug 0 0 0
1080 0 return 1;
1081 } elsif ($$tr =~ s#^now $break##x) {
1082 0 $$rdr = 0;
1083 0 return 1;
1084 }
1085 0 return 0;
1086 }
1087  
1088 sub debug_display
1089 0 ▶{
Subroutine debug_display: not called CC=12 SCAR=50.5
Pod undocumented
1090 0 my ($tz, $tzo, $H, $M, $S, $m, $d, $y, $rs, $rd, $rel, $passes, $parse, $t) = @_;
1091 0 print "---------<<\n";
1092 0 ▶ print defined($tz) ? "tz: $tz.\n" : "no tz\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $tz ? : 0 0 0
1093 0 ▶ print defined($tzo) ? "tzo: $tzo.\n" : "no tzo\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $tzo ? : 0 0 0
1094 0 print "HMS: ";
1095 0 ▶ print defined($H) ? "$H, " : "no H, ";
Branch: 1 branch
BranchTrueFalseTotal
defined $H ? : 0 0 0
1096 0 ▶ print defined($M) ? "$M, " : "no M, ";
Branch: 1 branch
BranchTrueFalseTotal
defined $M ? : 0 0 0
1097 0 ▶ print defined($S) ? "$S\n" : "no S.\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $S ? : 0 0 0
1098 0 print "mdy: ";
1099 0 ▶ print defined($m) ? "$m, " : "no m, ";
Branch: 1 branch
BranchTrueFalseTotal
defined $m ? : 0 0 0
1100 0 ▶ print defined($d) ? "$d, " : "no d, ";
Branch: 1 branch
BranchTrueFalseTotal
defined $d ? : 0 0 0
1101 0 ▶ print defined($y) ? "$y\n" : "no y.\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $y ? : 0 0 0
1102 0 ▶ print defined($rs) ? "rs: $rs.\n" : "no rs\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $rs ? : 0 0 0
1103 0 ▶ print defined($rd) ? "rd: $rd.\n" : "no rd\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $rd ? : 0 0 0
1104 0 ▶ print $rel ? "relative\n" : "not relative\n";
Branch: 1 branch
BranchTrueFalseTotal
$rel ? : 0 0 0
1105 0 print "passes: $passes\n";
1106 0 print "parse:$parse\n";
1107 0 print "t: $t.\n";
1108 0 print "--------->>\n";
1109 }
1110 5 1;
1111  
1112 __END__
↑ Summary Timezone.pm »