###############################################################################
## Copyright (c) 1995 - 2002 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. ##
###############################################################################
use vars
qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
@ISA = qw(Exporter DynaLoader);
Nth_Weekday_of_Month_Year
%EXPORT_TAGS = (all
=> [@EXPORT_OK]);
##################################################
## "Version()" is available but not exported ##
## in order to avoid possible name clashes. ##
## Call with "Date::Calc::Version()" instead! ##
##################################################
bootstrap Date
::Calc
$VERSION;
die "Usage: (\$year,\$month,\$day) = Decode_Date_EU2(\$date);\n"
my($year,$month,$day,$length);
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);
return(); # can't decode month!
elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x)
$length = length($buffer);
$day = substr($buffer,0,1);
$month = substr($buffer,1,1);
$year = substr($buffer,2,1);
$day = substr($buffer,0,1);
$month = substr($buffer,1,1);
$year = substr($buffer,2,2);
$day = substr($buffer,0,1);
$month = substr($buffer,1,2);
$year = substr($buffer,3,2);
$day = substr($buffer,0,2);
$month = substr($buffer,2,2);
$year = substr($buffer,4,2);
$day = substr($buffer,0,1);
$month = substr($buffer,1,2);
$year = substr($buffer,3,4);
$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!
die "Usage: (\$year,\$month,\$day) = Decode_Date_US2(\$date);\n"
my($year,$month,$day,$length);
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);
return(); # can't decode month!
$length = length($buffer);
$day = substr($buffer,0,1);
$year = substr($buffer,1,1);
$day = substr($buffer,0,1);
$year = substr($buffer,1,2);
$day = substr($buffer,0,2);
$year = substr($buffer,2,2);
$day = substr($buffer,0,1);
$year = substr($buffer,1,4);
$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);
return(); # can't decode month!
elsif ($buffer =~ /^\D* 0*(\d+) \D*$/x)
$length = length($buffer);
$month = substr($buffer,0,1);
$day = substr($buffer,1,1);
$year = substr($buffer,2,1);
$month = substr($buffer,0,1);
$day = substr($buffer,1,1);
$year = substr($buffer,2,2);
$month = substr($buffer,0,1);
$day = substr($buffer,1,2);
$year = substr($buffer,3,2);
$month = substr($buffer,0,2);
$day = substr($buffer,2,2);
$year = substr($buffer,4,2);
$month = substr($buffer,0,1);
$day = substr($buffer,1,2);
$year = substr($buffer,3,4);
$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!
die "Usage: (\$year,\$month,\$day) = Parse_Date(\$date);\n"
unless ($date =~ /\b([JFMASOND][aepuco][nbrynlgptvc])\s+([0123]??\d)\b/)
unless ($date =~ /\b(19\d\d|20\d\d)\b/)
$month = Decode_Month
($month);
unless (check_date
($year,$month,$day))
return($year,$month,$day);