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