| 1 | |||||||||||||||||||||||||||||||
| 2 | ############################################################################### | ||||||||||||||||||||||||||||||
| 3 | ## ## | ||||||||||||||||||||||||||||||
| 4 | ## Copyright (c) 1995 - 2015 by Steffen Beyer. ## | ||||||||||||||||||||||||||||||
| 5 | ## All rights reserved. ## | ||||||||||||||||||||||||||||||
| 6 | ## ## | ||||||||||||||||||||||||||||||
| 7 | ## This package is free software; you can redistribute it ## | ||||||||||||||||||||||||||||||
| 8 | ## and/or modify it under the same terms as Perl itself. ## | ||||||||||||||||||||||||||||||
| 9 | ## ## | ||||||||||||||||||||||||||||||
| 10 | ############################################################################### | ||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||
| 12 | package Date::Calc::XS; | ||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||
| 14 | 50 | ▶ | BEGIN { eval { require bytes; }; } | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 15 | 50 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 16 | 50 | ▶ | use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||
| 18 | 50 | ▶ | use Carp::Clan qw(^Date::); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||
| 20 | 50 | require Exporter; | |||||||||||||||||||||||||||||
| 21 | 50 | require DynaLoader; | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||
| 23 | 50 | @ISA = qw(Exporter DynaLoader); | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||
| 25 | 50 | @EXPORT = qw(); | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||
| 27 | 50 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||||
| 28 | Days_in_Year | ||||||||||||||||||||||||||||||
| 29 | Days_in_Month | ||||||||||||||||||||||||||||||
| 30 | Weeks_in_Year | ||||||||||||||||||||||||||||||
| 31 | leap_year | ||||||||||||||||||||||||||||||
| 32 | check_date | ||||||||||||||||||||||||||||||
| 33 | check_time | ||||||||||||||||||||||||||||||
| 34 | check_business_date | ||||||||||||||||||||||||||||||
| 35 | Day_of_Year | ||||||||||||||||||||||||||||||
| 36 | Date_to_Days | ||||||||||||||||||||||||||||||
| 37 | Day_of_Week | ||||||||||||||||||||||||||||||
| 38 | Week_Number | ||||||||||||||||||||||||||||||
| 39 | Week_of_Year | ||||||||||||||||||||||||||||||
| 40 | Monday_of_Week | ||||||||||||||||||||||||||||||
| 41 | Nth_Weekday_of_Month_Year | ||||||||||||||||||||||||||||||
| 42 | Standard_to_Business | ||||||||||||||||||||||||||||||
| 43 | Business_to_Standard | ||||||||||||||||||||||||||||||
| 44 | Delta_Days | ||||||||||||||||||||||||||||||
| 45 | Delta_DHMS | ||||||||||||||||||||||||||||||
| 46 | Delta_YMD | ||||||||||||||||||||||||||||||
| 47 | Delta_YMDHMS | ||||||||||||||||||||||||||||||
| 48 | N_Delta_YMD | ||||||||||||||||||||||||||||||
| 49 | N_Delta_YMDHMS | ||||||||||||||||||||||||||||||
| 50 | Normalize_DHMS | ||||||||||||||||||||||||||||||
| 51 | Add_Delta_Days | ||||||||||||||||||||||||||||||
| 52 | Add_Delta_DHMS | ||||||||||||||||||||||||||||||
| 53 | Add_Delta_YM | ||||||||||||||||||||||||||||||
| 54 | Add_Delta_YMD | ||||||||||||||||||||||||||||||
| 55 | Add_Delta_YMDHMS | ||||||||||||||||||||||||||||||
| 56 | Add_N_Delta_YMD | ||||||||||||||||||||||||||||||
| 57 | Add_N_Delta_YMDHMS | ||||||||||||||||||||||||||||||
| 58 | System_Clock | ||||||||||||||||||||||||||||||
| 59 | Today | ||||||||||||||||||||||||||||||
| 60 | Now | ||||||||||||||||||||||||||||||
| 61 | Today_and_Now | ||||||||||||||||||||||||||||||
| 62 | This_Year | ||||||||||||||||||||||||||||||
| 63 | Gmtime | ||||||||||||||||||||||||||||||
| 64 | Localtime | ||||||||||||||||||||||||||||||
| 65 | Mktime | ||||||||||||||||||||||||||||||
| 66 | Timezone | ||||||||||||||||||||||||||||||
| 67 | Date_to_Time | ||||||||||||||||||||||||||||||
| 68 | Time_to_Date | ||||||||||||||||||||||||||||||
| 69 | Easter_Sunday | ||||||||||||||||||||||||||||||
| 70 | Decode_Month | ||||||||||||||||||||||||||||||
| 71 | Decode_Day_of_Week | ||||||||||||||||||||||||||||||
| 72 | Decode_Language | ||||||||||||||||||||||||||||||
| 73 | Decode_Date_EU | ||||||||||||||||||||||||||||||
| 74 | Decode_Date_US | ||||||||||||||||||||||||||||||
| 75 | Fixed_Window | ||||||||||||||||||||||||||||||
| 76 | Moving_Window | ||||||||||||||||||||||||||||||
| 77 | Compress | ||||||||||||||||||||||||||||||
| 78 | Uncompress | ||||||||||||||||||||||||||||||
| 79 | check_compressed | ||||||||||||||||||||||||||||||
| 80 | Compressed_to_Text | ||||||||||||||||||||||||||||||
| 81 | Date_to_Text | ||||||||||||||||||||||||||||||
| 82 | Date_to_Text_Long | ||||||||||||||||||||||||||||||
| 83 | English_Ordinal | ||||||||||||||||||||||||||||||
| 84 | Calendar | ||||||||||||||||||||||||||||||
| 85 | Month_to_Text | ||||||||||||||||||||||||||||||
| 86 | Day_of_Week_to_Text | ||||||||||||||||||||||||||||||
| 87 | Day_of_Week_Abbreviation | ||||||||||||||||||||||||||||||
| 88 | Language_to_Text | ||||||||||||||||||||||||||||||
| 89 | Language | ||||||||||||||||||||||||||||||
| 90 | Languages | ||||||||||||||||||||||||||||||
| 91 | Decode_Date_EU2 | ||||||||||||||||||||||||||||||
| 92 | Decode_Date_US2 | ||||||||||||||||||||||||||||||
| 93 | Parse_Date | ||||||||||||||||||||||||||||||
| 94 | ISO_LC | ||||||||||||||||||||||||||||||
| 95 | ISO_UC | ||||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||
| 98 | 50 | %EXPORT_TAGS = (all => [@EXPORT_OK]); | |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||
| 100 | ################################################## | ||||||||||||||||||||||||||||||
| 101 | ## ## | ||||||||||||||||||||||||||||||
| 102 | ## "Version()" is available but not exported ## | ||||||||||||||||||||||||||||||
| 103 | ## in order to avoid possible name clashes. ## | ||||||||||||||||||||||||||||||
| 104 | ## Call "Date::Calc::XS::Version()" instead! ## | ||||||||||||||||||||||||||||||
| 105 | ## ## | ||||||||||||||||||||||||||||||
| 106 | ################################################## | ||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||
| 108 | 50 | $VERSION = '6.4'; | |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||
| 110 | 50 | bootstrap Date::Calc::XS $VERSION; | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||
| 112 | sub Decode_Date_EU2 | ||||||||||||||||||||||||||||||
| 113 | 46 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
Decode_Date_EU2: called CC=17 SCAR=28.3
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 114 | 46 | ▶ | croak "Usage: (\$year,\$month,\$day) = Decode_Date_EU2(\$date[,\$lang]);\n" unless ((@_ == 1) or (@_ == 2)); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 or @_ == 2
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1
@_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
| |||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||
| 116 | 46 | my($buffer) = shift; | |||||||||||||||||||||||||||||
| 117 | 46 | ▶ | my($lang) = shift || 0; | ||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||
| 118 | 46 | my($year,$month,$day,$length); | |||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||
| 120 | 46 | ▶ | $lang = Language() unless (($lang >= 1) and ($lang <= Languages())); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lang >= 1 and $lang <= Languages()
MC/DC50%1/2
$lang >= 1 and $lang <= Languages()
$lang >= 1
$lang <= Languages()
Truth table66%2/3
A and B
A= $lang >= 1B= $lang <= Languages()
| |||||||||||||||||||||||||||||||
| 121 | 46 | ▶ | if ($buffer =~ /^\D* (\d+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* (\d+) \D*$/x) | ||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||
| 122 | { | ||||||||||||||||||||||||||||||
| 123 | 22 | ($day,$month,$year) = ($1,$2,$3); | |||||||||||||||||||||||||||||
| 124 | 22 | $month = Decode_Month($month,$lang); | |||||||||||||||||||||||||||||
| 125 | 22 | ▶ | unless ($month > 0) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 126 | { | ||||||||||||||||||||||||||||||
| 127 | 1 | return(); # can't decode month! | |||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||
| 130 | elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x) | ||||||||||||||||||||||||||||||
| 131 | { | ||||||||||||||||||||||||||||||
| 132 | 19 | $buffer = $1; | |||||||||||||||||||||||||||||
| 133 | 19 | $length = length($buffer); | |||||||||||||||||||||||||||||
| 134 | 19 | ▶ | if ($length == 3) | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||||||
| 136 | 3 | $day = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 137 | 3 | $month = substr($buffer,1,1); | |||||||||||||||||||||||||||||
| 138 | 3 | $year = substr($buffer,2,1); | |||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||
| 140 | elsif ($length == 4) | ||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||
| 142 | 3 | $day = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 143 | 3 | $month = substr($buffer,1,1); | |||||||||||||||||||||||||||||
| 144 | 3 | $year = substr($buffer,2,2); | |||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||
| 146 | elsif ($length == 5) | ||||||||||||||||||||||||||||||
| 147 | { | ||||||||||||||||||||||||||||||
| 148 | 3 | $day = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 149 | 3 | $month = substr($buffer,1,2); | |||||||||||||||||||||||||||||
| 150 | 3 | $year = substr($buffer,3,2); | |||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||
| 152 | elsif ($length == 6) | ||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||
| 154 | 3 | $day = substr($buffer,0,2); | |||||||||||||||||||||||||||||
| 155 | 3 | $month = substr($buffer,2,2); | |||||||||||||||||||||||||||||
| 156 | 3 | $year = substr($buffer,4,2); | |||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||
| 158 | elsif ($length == 7) | ||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||
| 160 | 3 | $day = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 161 | 3 | $month = substr($buffer,1,2); | |||||||||||||||||||||||||||||
| 162 | 3 | $year = substr($buffer,3,4); | |||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||
| 164 | elsif ($length == 8) | ||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||
| 166 | 3 | $day = substr($buffer,0,2); | |||||||||||||||||||||||||||||
| 167 | 3 | $month = substr($buffer,2,2); | |||||||||||||||||||||||||||||
| 168 | 3 | $year = substr($buffer,4,4); | |||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||
| 170 | 1 | else { return(); } # wrong number of digits! | |||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||
| 172 | elsif ($buffer =~ /^\D* (\d+) \D+ (\d+) \D+ (\d+) \D*$/x) | ||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||
| 174 | 3 | ($day,$month,$year) = ($1,$2,$3); | |||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||
| 176 | 2 | else { return(); } # no match at all! | |||||||||||||||||||||||||||||
| 177 | 42 | $year = Moving_Window($year); | |||||||||||||||||||||||||||||
| 178 | 42 | ▶ | if (check_date($year,$month,$day)) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||
| 180 | 40 | return($year,$month,$day); | |||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||
| 182 | 2 | else { return(); } # not a valid date! | |||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||
| 185 | sub Decode_Date_US2 | ||||||||||||||||||||||||||||||
| 186 | 46 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
Decode_Date_US2: called CC=24 SCAR=32.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 187 | 46 | ▶ | croak "Usage: (\$year,\$month,\$day) = Decode_Date_US2(\$date[,\$lang]);\n" unless ((@_ == 1) or (@_ == 2)); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 or @_ == 2
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1
@_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
| |||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||
| 189 | 46 | my($buffer) = shift; | |||||||||||||||||||||||||||||
| 190 | 46 | ▶ | my($lang) = shift || 0; | ||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||
| 191 | 46 | my($year,$month,$day,$length); | |||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||
| 193 | 46 | ▶ | $lang = Language() unless (($lang >= 1) and ($lang <= Languages())); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lang >= 1 and $lang <= Languages()
MC/DC50%1/2
$lang >= 1 and $lang <= Languages()
$lang >= 1
$lang <= Languages()
Truth table66%2/3
A and B
A= $lang >= 1B= $lang <= Languages()
| |||||||||||||||||||||||||||||||
| 194 | 46 | ▶ | if ($buffer =~ /^[^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* 0*(\d+) \D*$/x) | ||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||
| 196 | 14 | ($month,$buffer) = ($1,$2); | |||||||||||||||||||||||||||||
| 197 | 14 | $month = Decode_Month($month,$lang); | |||||||||||||||||||||||||||||
| 198 | 14 | ▶ | unless ($month > 0) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 199 | { | ||||||||||||||||||||||||||||||
| 200 | 0 | return(); # can't decode month! | |||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||
| 202 | 14 | $length = length($buffer); | |||||||||||||||||||||||||||||
| 203 | 14 | ▶ | if ($length == 2) | ||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||
| 204 | { | ||||||||||||||||||||||||||||||
| 205 | 0 | $day = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 206 | 0 | $year = substr($buffer,1,1); | |||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||
| 208 | elsif ($length == 3) | ||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||
| 210 | 3 | $day = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 211 | 3 | $year = substr($buffer,1,2); | |||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||
| 213 | elsif ($length == 4) | ||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||
| 215 | 4 | $day = substr($buffer,0,2); | |||||||||||||||||||||||||||||
| 216 | 4 | $year = substr($buffer,2,2); | |||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||
| 218 | elsif ($length == 5) | ||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||
| 220 | 3 | $day = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 221 | 3 | $year = substr($buffer,1,4); | |||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||
| 223 | elsif ($length == 6) | ||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||
| 225 | 4 | $day = substr($buffer,0,2); | |||||||||||||||||||||||||||||
| 226 | 4 | $year = substr($buffer,2,4); | |||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||
| 228 | 0 | else { return(); } # wrong number of digits! | |||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||
| 230 | elsif ($buffer =~ /^[^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* ([A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\xFF]+) [^A-Za-z0-9\xC0-\xD6\xD8-\xF6\xF8-\xFF]* (\d+) \D+ (\d+) \D*$/x) | ||||||||||||||||||||||||||||||
| 231 | { | ||||||||||||||||||||||||||||||
| 232 | 8 | ($month,$day,$year) = ($1,$2,$3); | |||||||||||||||||||||||||||||
| 233 | 8 | $month = Decode_Month($month,$lang); | |||||||||||||||||||||||||||||
| 234 | 8 | ▶ | unless ($month > 0) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||
| 236 | 1 | return(); # can't decode month! | |||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||
| 239 | elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x) | ||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||
| 241 | 19 | $buffer = $1; | |||||||||||||||||||||||||||||
| 242 | 19 | $length = length($buffer); | |||||||||||||||||||||||||||||
| 243 | 19 | ▶ | if ($length == 3) | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||||||||||
| 245 | 3 | $month = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 246 | 3 | $day = substr($buffer,1,1); | |||||||||||||||||||||||||||||
| 247 | 3 | $year = substr($buffer,2,1); | |||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||
| 249 | elsif ($length == 4) | ||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||
| 251 | 3 | $month = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 252 | 3 | $day = substr($buffer,1,1); | |||||||||||||||||||||||||||||
| 253 | 3 | $year = substr($buffer,2,2); | |||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||
| 255 | elsif ($length == 5) | ||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||
| 257 | 3 | $month = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 258 | 3 | $day = substr($buffer,1,2); | |||||||||||||||||||||||||||||
| 259 | 3 | $year = substr($buffer,3,2); | |||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||
| 261 | elsif ($length == 6) | ||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||
| 263 | 3 | $month = substr($buffer,0,2); | |||||||||||||||||||||||||||||
| 264 | 3 | $day = substr($buffer,2,2); | |||||||||||||||||||||||||||||
| 265 | 3 | $year = substr($buffer,4,2); | |||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||
| 267 | elsif ($length == 7) | ||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||
| 269 | 3 | $month = substr($buffer,0,1); | |||||||||||||||||||||||||||||
| 270 | 3 | $day = substr($buffer,1,2); | |||||||||||||||||||||||||||||
| 271 | 3 | $year = substr($buffer,3,4); | |||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||
| 273 | elsif ($length == 8) | ||||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||||
| 275 | 3 | $month = substr($buffer,0,2); | |||||||||||||||||||||||||||||
| 276 | 3 | $day = substr($buffer,2,2); | |||||||||||||||||||||||||||||
| 277 | 3 | $year = substr($buffer,4,4); | |||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||
| 279 | 1 | else { return(); } # wrong number of digits! | |||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||
| 281 | elsif ($buffer =~ /^\D* (\d+) \D+ (\d+) \D+ (\d+) \D*$/x) | ||||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||||
| 283 | 3 | ($month,$day,$year) = ($1,$2,$3); | |||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||
| 285 | 2 | else { return(); } # no match at all! | |||||||||||||||||||||||||||||
| 286 | 42 | $year = Moving_Window($year); | |||||||||||||||||||||||||||||
| 287 | 42 | ▶ | if (check_date($year,$month,$day)) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||||
| 289 | 40 | return($year,$month,$day); | |||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||
| 291 | 2 | else { return(); } # not a valid date! | |||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||
| 294 | sub Parse_Date | ||||||||||||||||||||||||||||||
| 295 | 15 | ▶ | { | ||||||||||||||||||||||||||||
|
Subroutine
Parse_Date: called CC=10 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 296 | 15 | ▶ | croak "Usage: (\$year,\$month,\$day) = Parse_Date(\$date[,\$lang]);\n" unless ((@_ == 1) or (@_ == 2)); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 or @_ == 2
MC/DC0%0/2
@_ == 1 or @_ == 2
@_ == 1
@_ == 2
Truth table66%2/3
A or B
A= @_ == 1B= @_ == 2
| |||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||
| 298 | 15 | my($date) = shift; | |||||||||||||||||||||||||||||
| 299 | 15 | ▶ | my($lang) = shift || 0; | ||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||
| 300 | 15 | my($year,$month,$day); | |||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||
| 302 | 15 | ▶ | $lang = Language() unless (($lang >= 1) and ($lang <= Languages())); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$lang >= 1 and $lang <= Languages()
MC/DC50%1/2
$lang >= 1 and $lang <= Languages()
$lang >= 1
$lang <= Languages()
Truth table66%2/3
A and B
A= $lang >= 1B= $lang <= Languages()
| |||||||||||||||||||||||||||||||
| 303 | 15 | ▶ | unless ($date =~ /\b([\x41-\x5A\x61-\x7A\xC0-\xD6\xD8-\xF6\xF8-\xFF]{3})\s+([0123]??\d)\b/) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||
| 305 | 1 | return(); | |||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||
| 307 | 14 | $month = $1; | |||||||||||||||||||||||||||||
| 308 | 14 | $day = $2; | |||||||||||||||||||||||||||||
| 309 | 14 | ▶ | unless ($date =~ /\b(19\d\d|20\d\d)\b/) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 310 | { | ||||||||||||||||||||||||||||||
| 311 | 1 | return(); | |||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||
| 313 | 13 | $year = $1; | |||||||||||||||||||||||||||||
| 314 | 13 | $month = Decode_Month($month,$lang); | |||||||||||||||||||||||||||||
| 315 | 13 | ▶ | unless ($month > 0) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 316 | { | ||||||||||||||||||||||||||||||
| 317 | 0 | return(); | |||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||
| 319 | 13 | ▶ | unless (check_date($year,$month,$day)) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||
| 321 | 1 | return(); | |||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||
| 323 | 12 | return($year,$month,$day); | |||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||
| 326 | 50 | 1; | |||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||
| 328 | __END__ | ||||||||||||||||||||||||||||||