Changeset 618 for trunk/Cocoa/Pester/Source
- Timestamp:
- 03/02/10 08:03:19 (15 years ago)
- Location:
- trunk/Cocoa/Pester/Source
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/Manip.pm
r617 r618 1 1 package Date::Manip; 2 # Copyright (c) 1995-20 07Sullivan Beck. All rights reserved.2 # Copyright (c) 1995-2010 Sullivan Beck. All rights reserved. 3 3 # This program is free software; you can redistribute it and/or modify it 4 4 # under the same terms as Perl itself. … … 6 6 ########################################################################### 7 7 ########################################################################### 8 9 use warnings; 8 10 9 11 use vars qw($OS %Lang %Holiday %Events %Curr %Cnf %Zone $VERSION @ISA @EXPORT); … … 37 39 38 40 # Determine if we're doing taint checking 39 $Date::Manip::NoTaint = eval { local $^W=0; eval("#" . substr($^X, 0, 0)); 1 }; 41 #if ($] < 5.0080) { 42 $Date::Manip::NoTaint = eval { local $^W=0; eval("#" . substr($^X, 0, 0)); 1 }; 43 #} else { 44 # $Date::Manip::NoTaint = (${^TAINT} == 0 ? 1 : 0); 45 #} 40 46 41 47 ########################################################################### … … 212 218 use IO::File; 213 219 214 $VERSION="5.47"; 220 use vars qw($Abbrevs); 221 use Date::Manip::DM5abbrevs; 222 223 $VERSION="5.55"; 215 224 216 225 ######################################################################## … … 242 251 no strict "vars"; 243 252 # This sorts from longest to shortest element 244 sub sortByLength {253 sub _sortByLength { 245 254 return (length $b <=> length $a); 246 255 } … … 276 285 if ($val) { 277 286 $Curr{"InitFilesRead"}=0; 278 &EraseHolidays();287 EraseHolidays(); 279 288 } 280 289 } elsif ($var =~ /^PathSep$/i) { … … 290 299 $Cnf{"IgnoreGlobalCnf"}=1; 291 300 } elsif ($var =~ /^EraseHolidays$/i) { 292 &EraseHolidays();301 EraseHolidays(); 293 302 } else { 294 303 push(@tmp,$_); … … 302 311 303 312 if ($Cnf{"GlobalCnf"}) { 304 $file= &ExpandTilde($Cnf{"GlobalCnf"});305 &Date_InitFile($file) if ($file);313 $file=_ExpandTilde($Cnf{"GlobalCnf"}); 314 _Date_InitFile($file) if ($file); 306 315 } 307 316 } … … 312 321 313 322 if ($Cnf{"PersonalCnf"} and $Cnf{"PersonalCnfPath"}) { 314 $file= &SearchPath($Cnf{"PersonalCnf"},$Cnf{"PersonalCnfPath"},"r");315 &Date_InitFile($file) if ($file);323 $file=_SearchPath($Cnf{"PersonalCnf"},$Cnf{"PersonalCnfPath"},"r"); 324 _Date_InitFile($file) if ($file); 316 325 } 317 326 } … … 323 332 ($var,$val)=($1,$2); 324 333 $val="" if (! defined $val); 325 &Date_SetConfigVariable($var,$val);334 _Date_SetConfigVariable($var,$val); 326 335 } 327 336 328 337 confess "ERROR: Unknown FirstDay in Date::Manip.\n" 329 if (! &IsInt($Cnf{"FirstDay"},1,7));338 if (! _IsInt($Cnf{"FirstDay"},1,7)); 330 339 confess "ERROR: Unknown WorkWeekBeg in Date::Manip.\n" 331 if (! &IsInt($Cnf{"WorkWeekBeg"},1,7));340 if (! _IsInt($Cnf{"WorkWeekBeg"},1,7)); 332 341 confess "ERROR: Unknown WorkWeekEnd in Date::Manip.\n" 333 if (! &IsInt($Cnf{"WorkWeekEnd"},1,7));342 if (! _IsInt($Cnf{"WorkWeekEnd"},1,7)); 334 343 confess "ERROR: Invalid WorkWeek in Date::Manip.\n" 335 344 if ($Cnf{"WorkWeekEnd"} <= $Cnf{"WorkWeekBeg"}); … … 338 347 $tmp,%tmp,$tmp2,@tmp2, 339 348 $i,$j,@tmp3, 340 $zonesrfc,@zones)=();349 @zones)=(); 341 350 342 351 my($L)=$Cnf{"Language"}; … … 346 355 347 356 if ($L eq "English") { 348 &Date_Init_English(\%lang);357 _Date_Init_English(\%lang); 349 358 350 359 } elsif ($L eq "French") { 351 &Date_Init_French(\%lang);360 _Date_Init_French(\%lang); 352 361 353 362 } elsif ($L eq "Swedish") { 354 &Date_Init_Swedish(\%lang);363 _Date_Init_Swedish(\%lang); 355 364 356 365 } elsif ($L eq "German") { 357 &Date_Init_German(\%lang);366 _Date_Init_German(\%lang); 358 367 359 368 } elsif ($L eq "Polish") { 360 &Date_Init_Polish(\%lang);369 _Date_Init_Polish(\%lang); 361 370 362 371 } elsif ($L eq "Dutch" || 363 372 $L eq "Nederlands") { 364 &Date_Init_Dutch(\%lang);373 _Date_Init_Dutch(\%lang); 365 374 366 375 } elsif ($L eq "Spanish") { 367 &Date_Init_Spanish(\%lang);376 _Date_Init_Spanish(\%lang); 368 377 369 378 } elsif ($L eq "Portuguese") { 370 &Date_Init_Portuguese(\%lang);379 _Date_Init_Portuguese(\%lang); 371 380 372 381 } elsif ($L eq "Romanian") { 373 &Date_Init_Romanian(\%lang);382 _Date_Init_Romanian(\%lang); 374 383 375 384 } elsif ($L eq "Italian") { 376 &Date_Init_Italian(\%lang);385 _Date_Init_Italian(\%lang); 377 386 378 387 } elsif ($L eq "Russian") { 379 &Date_Init_Russian(\%lang);388 _Date_Init_Russian(\%lang); 380 389 381 390 } elsif ($L eq "Turkish") { 382 &Date_Init_Turkish(\%lang);391 _Date_Init_Turkish(\%lang); 383 392 384 393 } elsif ($L eq "Danish") { 385 &Date_Init_Danish(\%lang);394 _Date_Init_Danish(\%lang); 386 395 387 396 } elsif ($L eq "Catalan") { 388 &Date_Init_Catalan(\%lang);397 _Date_Init_Catalan(\%lang); 389 398 390 399 } else { … … 401 410 $Lang{$L}{"MonthL"}=[]; 402 411 $Lang{$L}{"MonL"}=[]; 403 &Date_InitLists([$lang{"month_name"},412 _Date_InitLists([$lang{"month_name"}, 404 413 $lang{"month_abb"}], 405 414 \$Lang{$L}{"Month"},"lc,sort,back", … … 419 428 $Lang{$L}{"WkL"}=[]; 420 429 $Lang{$L}{"WL"}=[]; 421 &Date_InitLists([$lang{"day_name"},430 _Date_InitLists([$lang{"day_name"}, 422 431 $lang{"day_abb"}], 423 432 \$Lang{$L}{"Week"},"lc,sort,back", … … 425 434 $Lang{$L}{"WkL"}], 426 435 [$Lang{$L}{"WeekH"},1]); 427 &Date_InitLists([$lang{"day_char"}],436 _Date_InitLists([$lang{"day_char"}], 428 437 "","lc", 429 438 [$Lang{$L}{"WL"}], … … 446 455 447 456 $Lang{$L}{"LastL"}=$lang{"last"}; 448 &Date_InitStrings($lang{"last"},457 _Date_InitStrings($lang{"last"}, 449 458 \$Lang{$L}{"Last"},"lc,sort"); 450 459 451 460 $Lang{$L}{"EachL"}=$lang{"each"}; 452 &Date_InitStrings($lang{"each"},461 _Date_InitStrings($lang{"each"}, 453 462 \$Lang{$L}{"Each"},"lc,sort"); 454 463 455 464 $Lang{$L}{"DoMH"}={}; 456 465 $Lang{$L}{"DoML"}=[]; 457 &Date_InitLists([$lang{"num_suff"},466 _Date_InitLists([$lang{"num_suff"}, 458 467 $lang{"num_word"}], 459 468 \$Lang{$L}{"DoM"},"lc,sort,back,escape", … … 474 483 push(@tmp,$tmp); 475 484 } 476 &Date_InitStrings(\@tmp,\$Lang{$L}{"WoM"},485 _Date_InitStrings(\@tmp,\$Lang{$L}{"WoM"}, 477 486 "lc,sort,back,escape"); 478 487 … … 484 493 # PMstr = "PM" 485 494 486 &Date_InitStrings($lang{"am"},\$Lang{$L}{"AM"},"lc,sort,escape");487 &Date_InitStrings($lang{"pm"},\$Lang{$L}{"PM"},"lc,sort,escape");488 &Date_InitStrings([ @{$lang{"am"}},@{$lang{"pm"}} ],\$Lang{$L}{"AmPm"},495 _Date_InitStrings($lang{"am"},\$Lang{$L}{"AM"},"lc,sort,escape"); 496 _Date_InitStrings($lang{"pm"},\$Lang{$L}{"PM"},"lc,sort,escape"); 497 _Date_InitStrings([ @{$lang{"am"}},@{$lang{"pm"}} ],\$Lang{$L}{"AmPm"}, 489 498 "lc,back,sort,escape"); 490 499 $Lang{$L}{"AMstr"}=$lang{"am"}[0]; … … 506 515 # (so there is no confusion between Mn and Month). 507 516 508 &Date_InitStrings($lang{"years"} ,\$Lang{$L}{"Yabb"}, "lc,sort");509 &Date_InitStrings($lang{"months"} ,\$Lang{$L}{"Mabb"}, "lc,sort");510 &Date_InitStrings($lang{"weeks"} ,\$Lang{$L}{"Wabb"}, "lc,sort");511 &Date_InitStrings($lang{"days"} ,\$Lang{$L}{"Dabb"}, "lc,sort");512 &Date_InitStrings($lang{"hours"} ,\$Lang{$L}{"Habb"}, "lc,sort");513 &Date_InitStrings($lang{"minutes"},\$Lang{$L}{"MNabb"},"lc,sort");514 &Date_InitStrings($lang{"seconds"},\$Lang{$L}{"Sabb"}, "lc,sort");517 _Date_InitStrings($lang{"years"} ,\$Lang{$L}{"Yabb"}, "lc,sort"); 518 _Date_InitStrings($lang{"months"} ,\$Lang{$L}{"Mabb"}, "lc,sort"); 519 _Date_InitStrings($lang{"weeks"} ,\$Lang{$L}{"Wabb"}, "lc,sort"); 520 _Date_InitStrings($lang{"days"} ,\$Lang{$L}{"Dabb"}, "lc,sort"); 521 _Date_InitStrings($lang{"hours"} ,\$Lang{$L}{"Habb"}, "lc,sort"); 522 _Date_InitStrings($lang{"minutes"},\$Lang{$L}{"MNabb"},"lc,sort"); 523 _Date_InitStrings($lang{"seconds"},\$Lang{$L}{"Sabb"}, "lc,sort"); 515 524 $Lang{$L}{"Repl"}={}; 516 &Date_InitHash($lang{"replace"},undef,"lc",$Lang{$L}{"Repl"});525 _Date_InitHash($lang{"replace"},undef,"lc",$Lang{$L}{"Repl"}); 517 526 518 527 # variables for special dates that are offsets from now … … 528 537 529 538 $Lang{$L}{"TimesH"}={}; 530 &Date_InitHash($lang{"times"},539 _Date_InitHash($lang{"times"}, 531 540 \$Lang{$L}{"Times"},"lc,sort,back", 532 541 $Lang{$L}{"TimesH"}); 533 &Date_InitStrings($lang{"now"},\$Lang{$L}{"Now"},"lc,sort");534 &Date_InitStrings($lang{"today"},\$Lang{$L}{"Today"},"lc,sort");542 _Date_InitStrings($lang{"now"},\$Lang{$L}{"Now"},"lc,sort"); 543 _Date_InitStrings($lang{"today"},\$Lang{$L}{"Today"},"lc,sort"); 535 544 $Lang{$L}{"OffsetH"}={}; 536 &Date_InitHash($lang{"offset"},545 _Date_InitHash($lang{"offset"}, 537 546 \$Lang{$L}{"Offset"},"lc,sort,back", 538 547 $Lang{$L}{"OffsetH"}); … … 547 556 # tz2z = hash of all tzdata timezones to full timezone (EST#EDT) 548 557 549 $zonesrfc=550 "idlw -1200 ". # International Date Line West551 "nt -1100 ". # Nome552 "hst -1000 ". # Hawaii Standard553 "cat -1000 ". # Central Alaska554 "ahst -1000 ". # Alaska-Hawaii Standard555 "akst -0900 ". # Alaska Standard556 "yst -0900 ". # Yukon Standard557 "hdt -0900 ". # Hawaii Daylight558 "akdt -0800 ". # Alaska Daylight559 "ydt -0800 ". # Yukon Daylight560 "pst -0800 ". # Pacific Standard561 "pdt -0700 ". # Pacific Daylight562 "mst -0700 ". # Mountain Standard563 "mdt -0600 ". # Mountain Daylight564 "cst -0600 ". # Central Standard565 "cdt -0500 ". # Central Daylight566 "est -0500 ". # Eastern Standard567 "act -0500 ". # Brazil, Acre568 "pet -0500 ". # Peruvian time569 "sat -0400 ". # Chile570 "clt -0400 ". # Chile571 "clst -0400 ". # Chile Standard572 "bot -0400 ". # Bolivia573 "amt -0400 ". # Brazil, Amazon574 "acst -0400 ". # Brazil, Acre Daylight575 "edt -0400 ". # Eastern Daylight576 "ast -0400 ". # Atlantic Standard577 #"nst -0330 ". # Newfoundland Standard nst=North Sumatra +0630578 "nft -0330 ". # Newfoundland579 #"gst -0300 ". # Greenland Standard gst=Guam Standard +1000580 "cldt -0300 ". # Chile Daylight581 #"bst -0300 ". # Brazil Standard bst=British Summer +0100582 "brt -0300 ". # Brazil Standard (official time)583 #"brst -0300 ". # Brazil Standard584 "adt -0300 ". # Atlantic Daylight585 "art -0300 ". # Argentina586 "amst -0300 ". # Brazil, Amazon Daylight587 "uyt -0300 ". # Uruguay588 "ndt -0230 ". # Newfoundland Daylight589 "brst -0200 ". # Brazil Daylight (official time)590 "fnt -0200 ". # Brazil, Fernando de Noronha591 "at -0200 ". # Azores592 "yust -0200 ". # Uruguay593 "wat -0100 ". # West Africa594 "fnst -0100 ". # Brazil, Fernando de Noronha Daylight595 "gmt +0000 ". # Greenwich Mean596 "ut +0000 ". # Universal597 "utc +0000 ". # Universal (Coordinated)598 "wet +0000 ". # Western European599 "cet +0100 ". # Central European600 "fwt +0100 ". # French Winter601 "met +0100 ". # Middle European602 "mez +0100 ". # Middle European603 "mewt +0100 ". # Middle European Winter604 "swt +0100 ". # Swedish Winter605 "bst +0100 ". # British Summer bst=Brazil standard -0300606 "gb +0100 ". # GMT with daylight savings607 "west +0100 ". # Western European Daylight608 "eet +0200 ". # Eastern Europe, USSR Zone 1609 "cest +0200 ". # Central European Summer610 "fst +0200 ". # French Summer611 "ist +0200 ". # Israel standard612 "mest +0200 ". # Middle European Summer613 "mesz +0200 ". # Middle European Summer614 "metdst +0200 ". # An alias for mest used by HP-UX615 "sast +0200 ". # South African Standard616 "sst +0200 ". # Swedish Summer sst=South Sumatra +0700617 "bt +0300 ". # Baghdad, USSR Zone 2618 "eest +0300 ". # Eastern Europe Summer619 "eetdst +0300 ". # An alias for eest used by HP-UX620 "eetedt +0300 ". # Eastern Europe, USSR Zone 1621 "idt +0300 ". # Israel Daylight622 "msk +0300 ". # Moscow623 "eat +0300 ". # East Africa624 "it +0330 ". # Iran625 "zp4 +0400 ". # USSR Zone 3626 "msd +0400 ". # Moscow Daylight627 "zp5 +0500 ". # USSR Zone 4628 "ist +0530 ". # Indian Standard629 "zp6 +0600 ". # USSR Zone 5630 "novt +0600 ". # Novosibirsk winter time zone, Russia631 "nst +0630 ". # North Sumatra nst=Newfoundland Std -0330632 #"sst +0700 ". # South Sumatra, USSR Zone 6 sst=Swedish Summer +0200633 "javt +0700 ". # Java634 "ict +0700 ". # Indo China Time635 "novst +0700 ". # Novosibirsk summer time zone, Russia636 "krat +0700 ". # Krasnoyarsk, Russia637 "myt +0800 ". # Malaysia638 "hkt +0800 ". # Hong Kong639 "sgt +0800 ". # Singapore640 "cct +0800 ". # China Coast, USSR Zone 7641 "krast +0800 ". # Krasnoyarsk, Russia Daylight642 "awst +0800 ". # Australian Western Standard643 "wst +0800 ". # West Australian Standard644 "pht +0800 ". # Asia Manila645 "kst +0900 ". # Republic of Korea646 "jst +0900 ". # Japan Standard, USSR Zone 8647 "rok +0900 ". # Republic of Korea648 "acst +0930 ". # Australian Central Standard649 "cast +0930 ". # Central Australian Standard650 "aest +1000 ". # Australian Eastern Standard651 "east +1000 ". # Eastern Australian Standard652 "gst +1000 ". # Guam Standard, USSR Zone 9 gst=Greenland Std -0300653 "chst +1000 ". # Guam Standard, USSR Zone 9 gst=Greenland Std -0300654 "acdt +1030 ". # Australian Central Daylight655 "cadt +1030 ". # Central Australian Daylight656 "aedt +1100 ". # Australian Eastern Daylight657 "eadt +1100 ". # Eastern Australian Daylight658 "idle +1200 ". # International Date Line East659 "nzst +1200 ". # New Zealand Standard660 "nzt +1200 ". # New Zealand661 "nzdt +1300 ". # New Zealand Daylight662 "z +0000 ".663 "a +0100 b +0200 c +0300 d +0400 e +0500 f +0600 g +0700 h +0800 ".664 "i +0900 k +1000 l +1100 m +1200 ".665 "n -0100 o -0200 p -0300 q -0400 r -0500 s -0600 t -0700 u -0800 ".666 "v -0900 w -1000 x -1100 y -1200";667 668 558 $Zone{"n2o"} = {}; 669 559 ($Zone{"zones"},%{ $Zone{"n2o"} })= 670 &Date_Regexp($zonesrfc,"sort,lc,under,back",560 _Date_Regexp($Abbrevs,"sort,lc,under,back", 671 561 "keys"); 672 562 … … 683 573 $Zone{"tz2z"} = {}; 684 574 ($Zone{"tzones"},%{ $Zone{"tz2z"} })= 685 &Date_Regexp($tmp,"lc,under,back","keys");686 $Cnf{"TZ"}= &Date_TimeZone;575 _Date_Regexp($tmp,"lc,under,back","keys"); 576 $Cnf{"TZ"}=Date_TimeZone(); 687 577 688 578 # misc. variables … … 696 586 # Prev = "(?:last|previous)" 697 587 698 &Date_InitStrings($lang{"at"}, \$Lang{$L}{"At"}, "lc,sort");699 &Date_InitStrings($lang{"on"}, \$Lang{$L}{"On"}, "lc,sort");700 &Date_InitStrings($lang{"future"},\$Lang{$L}{"Future"}, "lc,sort");701 &Date_InitStrings($lang{"later"}, \$Lang{$L}{"Later"}, "lc,sort");702 &Date_InitStrings($lang{"past"}, \$Lang{$L}{"Past"}, "lc,sort");703 &Date_InitStrings($lang{"next"}, \$Lang{$L}{"Next"}, "lc,sort");704 &Date_InitStrings($lang{"prev"}, \$Lang{$L}{"Prev"}, "lc,sort");705 &Date_InitStrings($lang{"of"}, \$Lang{$L}{"Of"}, "lc,sort");588 _Date_InitStrings($lang{"at"}, \$Lang{$L}{"At"}, "lc,sort"); 589 _Date_InitStrings($lang{"on"}, \$Lang{$L}{"On"}, "lc,sort"); 590 _Date_InitStrings($lang{"future"},\$Lang{$L}{"Future"}, "lc,sort"); 591 _Date_InitStrings($lang{"later"}, \$Lang{$L}{"Later"}, "lc,sort"); 592 _Date_InitStrings($lang{"past"}, \$Lang{$L}{"Past"}, "lc,sort"); 593 _Date_InitStrings($lang{"next"}, \$Lang{$L}{"Next"}, "lc,sort"); 594 _Date_InitStrings($lang{"prev"}, \$Lang{$L}{"Prev"}, "lc,sort"); 595 _Date_InitStrings($lang{"of"}, \$Lang{$L}{"Of"}, "lc,sort"); 706 596 707 597 # calc mode variables … … 710 600 # Business = "(?:business)" 711 601 712 &Date_InitStrings($lang{"exact"}, \$Lang{$L}{"Exact"}, "lc,sort");713 &Date_InitStrings($lang{"approx"}, \$Lang{$L}{"Approx"}, "lc,sort");714 &Date_InitStrings($lang{"business"},\$Lang{$L}{"Business"},"lc,sort");602 _Date_InitStrings($lang{"exact"}, \$Lang{$L}{"Exact"}, "lc,sort"); 603 _Date_InitStrings($lang{"approx"}, \$Lang{$L}{"Approx"}, "lc,sort"); 604 _Date_InitStrings($lang{"business"},\$Lang{$L}{"Business"},"lc,sort"); 715 605 716 606 ############### END OF LANGUAGE INITIALIZATION … … 728 618 } else { 729 619 confess "ERROR: Invalid WorkDayBeg in Date::Manip.\n" 730 if (! (($h1,$m1)= &CheckTime($Cnf{"WorkDayBeg"})));620 if (! (($h1,$m1)=_CheckTime($Cnf{"WorkDayBeg"}))); 731 621 $Cnf{"WorkDayBeg"}="$h1:$m1"; 732 622 confess "ERROR: Invalid WorkDayEnd in Date::Manip.\n" 733 if (! (($h2,$m2)= &CheckTime($Cnf{"WorkDayEnd"})));623 if (! (($h2,$m2)=_CheckTime($Cnf{"WorkDayEnd"}))); 734 624 $Cnf{"WorkDayEnd"}="$h2:$m2"; 735 625 … … 759 649 $m++; 760 650 } 761 &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk);651 _Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk); 762 652 $Curr{"Y"}=$y; 763 653 $Curr{"M"}=$m; … … 767 657 $Curr{"S"}=$s; 768 658 $Curr{"AmPm"}=$ampm; 769 $Curr{"Now"}= &Date_Join($y,$m,$d,$h,$mn,$s);659 $Curr{"Now"}=_Date_Join($y,$m,$d,$h,$mn,$s); 770 660 if ($Cnf{"TodayIsMidnight"}) { 771 $Curr{"Today"}= &Date_Join($y,$m,$d,0,0,0);661 $Curr{"Today"}=_Date_Join($y,$m,$d,0,0,0); 772 662 } else { 773 663 $Curr{"Today"}=$Curr{"Now"}; … … 807 697 808 698 # We only need to reinitialize if we have to determine what NOW is. 809 &Date_Init() if (! $Curr{"InitDone"} or $Cnf{"UpdateCurrTZ"});699 Date_Init() if (! $Curr{"InitDone"} or $Cnf{"UpdateCurrTZ"}); 810 700 811 701 my($L)=$Cnf{"Language"}; … … 849 739 850 740 $delta=""; 851 $delta= &ParseDateDelta($_) if (/[^:0-9]/);741 $delta=ParseDateDelta($_) if (/[^:0-9]/); 852 742 853 743 # Put parse in a simple loop for an easy exit. 854 744 PARSE: { 855 my(@tmp)= &Date_Split($_);745 my(@tmp)=_Date_Split($_); 856 746 if (@tmp) { 857 747 ($y,$m,$d,$h,$mn,$s)=@tmp; … … 894 784 # Other regular expressions 895 785 896 my($D4)='(\d{4})'; # 4 digits (yr)897 my($YY)='(\d{4}|\d{2})'; # 2 or 4 digits (yr)898 my($DD)='(\d{2})'; # 2 digits (mon/day/hr/min/sec)899 my($D) ='(\d{1,2})'; # 1 or 2 digit (mon/day/hr)900 my($FS)="(?:$ss\\d+)?"; # fractional secs901 my($sep)='[\/.-]'; # non-ISO8601 m/d/yy separators786 my($D4)='(\d{4})'; # 4 digits (yr) 787 my($YY)='(\d{4}|\d{2})'; # 2 or 4 digits (yr) 788 my($DD)='(\d{2})'; # 2 digits (mon/day/hr/min/sec) 789 my($D) ='(\d{1,2})'; # 1 or 2 digit (mon/day/hr) 790 my($FS)="(?:$ss\\d+)?"; # fractional secs 791 my($sep)='[\/.-]'; # non-ISO8601 m/d/yy separators 902 792 # absolute time zone +0700 (GMT) 903 my($hzone)='(?:[0-1][0-9]|2[0-3])'; 904 my($mzone)='(?:[0-5][0-9])'; 793 my($hzone)='(?:[0-1][0-9]|2[0-3])'; # 00 - 23 794 my($mzone)='(?:[0-5][0-9])'; # 00 - 59 905 795 my($zone2)='(?:\s*([+-](?:'."$hzone$mzone|$hzone:$mzone|$hzone))". 906 907 '(?:\s*\([^)]+\))?)'; 796 # +0700 +07:00 -07 797 '(?:\s*\([^)]+\))?)'; # (GMT) 908 798 909 799 # A regular expression for the time EXCEPT for the hour part … … 980 870 } 981 871 $time=1; 982 &Date_TimeCheck(\$h,\$mn,\$s,\$ampm);872 _Date_TimeCheck(\$h,\$mn,\$s,\$ampm); 983 873 $y=$m=$d=""; 984 874 # We're going to be calling TimeCheck again below (when we check the … … 987 877 $ampm=""; 988 878 if (/^\s*$/) { 989 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});879 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 990 880 last PARSE; 991 881 } … … 1070 960 # YY-W##-D 1071 961 ($y,$wofm,$dofw)=($1,$2,$3); 1072 ($y,$m,$d)= &Date_NthWeekOfYear($y,$wofm,$dofw);962 ($y,$m,$d)=_Date_NthWeekOfYear($y,$wofm,$dofw); 1073 963 last PARSE; 1074 964 … … 1077 967 # YYDOY 1078 968 ($y,$which)=($1,$2); 1079 ($y,$m,$d)= &Date_NthDayOfYear($y,$which);969 ($y,$m,$d)=Date_NthDayOfYear($y,$which); 1080 970 last PARSE; 1081 971 … … 1093 983 return "" if ($Curr{"InCalc"} && $delta); 1094 984 if ($delta) { 1095 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1096 return &DateCalc_DateDelta($Curr{"Now"},$delta);985 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 986 return _DateCalc_DateDelta($Curr{"Now"},$delta); 1097 987 } 1098 988 … … 1110 1000 ($wofm,$dofw,$m,$y)=($1,$2,$3,$4); 1111 1001 # fix $m, $y 1112 return "" if ( &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));1002 return "" if (_Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk)); 1113 1003 $dofw=$week{lc($dofw)}; 1114 1004 $wofm=$wom{lc($wofm)}; 1115 1005 # Get the first day of the month 1116 $date= &Date_Join($y,$m,1,$h,$mn,$s);1006 $date=_Date_Join($y,$m,1,$h,$mn,$s); 1117 1007 if ($wofm==-1) { 1118 $date= &DateCalc_DateDelta($date,"+0:1:0:0:0:0:0",\$err,0);1119 $date= &Date_GetPrev($date,$dofw,0);1008 $date=_DateCalc_DateDelta($date,"+0:1:0:0:0:0:0",\$err,0); 1009 $date=Date_GetPrev($date,$dofw,0); 1120 1010 } else { 1121 1011 for ($i=0; $i<$wofm; $i++) { 1122 1012 if ($i==0) { 1123 $date= &Date_GetNext($date,$dofw,1);1013 $date=Date_GetNext($date,$dofw,1); 1124 1014 } else { 1125 $date= &Date_GetNext($date,$dofw,0);1015 $date=Date_GetNext($date,$dofw,0); 1126 1016 } 1127 1017 } … … 1132 1022 # last day in month 1133 1023 ($m,$y)=($1,$2); 1134 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1135 $y= &Date_FixYear($y) if (! defined $y or length($y)<4);1024 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1025 $y=_Date_FixYear($y) if (! defined $y or length($y)<4); 1136 1026 $m=$month{lc($m)}; 1137 $d= &Date_DaysInMonth($m,$y);1027 $d=Date_DaysInMonth($m,$y); 1138 1028 last PARSE; 1139 1029 … … 1141 1031 # friday 1142 1032 ($dofw)=($1); 1143 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1144 $date= &Date_GetPrev($Curr{"Now"},$Cnf{"FirstDay"},1);1145 $date= &Date_GetNext($date,$dofw,1,$h,$mn,$s);1033 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1034 $date=Date_GetPrev($Curr{"Now"},$Cnf{"FirstDay"},1); 1035 $date=Date_GetNext($date,$dofw,1,$h,$mn,$s); 1146 1036 last PARSE; 1147 1037 … … 1149 1039 # next friday 1150 1040 ($dofw)=($1); 1151 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1152 $date= &Date_GetNext($Curr{"Now"},$dofw,0,$h,$mn,$s);1041 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1042 $date=Date_GetNext($Curr{"Now"},$dofw,0,$h,$mn,$s); 1153 1043 last PARSE; 1154 1044 … … 1156 1046 # last friday 1157 1047 ($dofw)=($1); 1158 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1159 $date= &Date_GetPrev($Curr{"Now"},$dofw,0,$h,$mn,$s);1048 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1049 $date=Date_GetPrev($Curr{"Now"},$dofw,0,$h,$mn,$s); 1160 1050 last PARSE; 1161 1051 1162 1052 } elsif (/^$next$wkabb$/i) { 1163 1053 # next week 1164 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1165 $date= &DateCalc_DateDelta($Curr{"Now"},"+0:0:1:0:0:0:0",\$err,0);1166 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1054 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1055 $date=_DateCalc_DateDelta($Curr{"Now"},"+0:0:1:0:0:0:0",\$err,0); 1056 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1167 1057 last PARSE; 1168 1058 } elsif (/^$prev$wkabb$/i) { 1169 1059 # last week 1170 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1171 $date= &DateCalc_DateDelta($Curr{"Now"},"-0:0:1:0:0:0:0",\$err,0);1172 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1060 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1061 $date=_DateCalc_DateDelta($Curr{"Now"},"-0:0:1:0:0:0:0",\$err,0); 1062 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1173 1063 last PARSE; 1174 1064 1175 1065 } elsif (/^$next$mabb$/i) { 1176 1066 # next month 1177 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1178 $date= &DateCalc_DateDelta($Curr{"Now"},"+0:1:0:0:0:0:0",\$err,0);1179 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1067 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1068 $date=_DateCalc_DateDelta($Curr{"Now"},"+0:1:0:0:0:0:0",\$err,0); 1069 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1180 1070 last PARSE; 1181 1071 } elsif (/^$prev$mabb$/i) { 1182 1072 # last month 1183 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1184 $date= &DateCalc_DateDelta($Curr{"Now"},"-0:1:0:0:0:0:0",\$err,0);1185 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1073 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1074 $date=_DateCalc_DateDelta($Curr{"Now"},"-0:1:0:0:0:0:0",\$err,0); 1075 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1186 1076 last PARSE; 1187 1077 … … 1191 1081 # 2 days later 1192 1082 ($num)=($1); 1193 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1194 $date= &DateCalc_DateDelta($Curr{"Now"},"+0:0:0:$num:0:0:0",1083 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1084 $date=_DateCalc_DateDelta($Curr{"Now"},"+0:0:0:$num:0:0:0", 1195 1085 \$err,0); 1196 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1086 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1197 1087 last PARSE; 1198 1088 } elsif (/^(\d+)$day$past$/i) { 1199 1089 # 2 days ago 1200 1090 ($num)=($1); 1201 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1202 $date= &DateCalc_DateDelta($Curr{"Now"},"-0:0:0:$num:0:0:0",1091 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1092 $date=_DateCalc_DateDelta($Curr{"Now"},"-0:0:0:$num:0:0:0", 1203 1093 \$err,0); 1204 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1094 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1205 1095 last PARSE; 1206 1096 … … 1210 1100 # 2 weeks later 1211 1101 ($num)=($1); 1212 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1213 $date= &DateCalc_DateDelta($Curr{"Now"},"+0:0:$num:0:0:0:0",1102 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1103 $date=_DateCalc_DateDelta($Curr{"Now"},"+0:0:$num:0:0:0:0", 1214 1104 \$err,0); 1215 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1105 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1216 1106 last PARSE; 1217 1107 } elsif (/^(\d+)$wkabb$past$/i) { 1218 1108 # 2 weeks ago 1219 1109 ($num)=($1); 1220 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1221 $date= &DateCalc_DateDelta($Curr{"Now"},"-0:0:$num:0:0:0:0",1110 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1111 $date=_DateCalc_DateDelta($Curr{"Now"},"-0:0:$num:0:0:0:0", 1222 1112 \$err,0); 1223 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1113 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1224 1114 last PARSE; 1225 1115 … … 1229 1119 # 2 months later 1230 1120 ($num)=($1); 1231 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1232 $date= &DateCalc_DateDelta($Curr{"Now"},"+0:$num:0:0:0:0:0",1121 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1122 $date=_DateCalc_DateDelta($Curr{"Now"},"+0:$num:0:0:0:0:0", 1233 1123 \$err,0); 1234 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1124 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1235 1125 last PARSE; 1236 1126 } elsif (/^(\d+)$mabb$past$/i) { 1237 1127 # 2 months ago 1238 1128 ($num)=($1); 1239 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1240 $date= &DateCalc_DateDelta($Curr{"Now"},"-0:$num:0:0:0:0:0",1129 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1130 $date=_DateCalc_DateDelta($Curr{"Now"},"-0:$num:0:0:0:0:0", 1241 1131 \$err,0); 1242 $date= &Date_SetTime($date,$h,$mn,$s) if (defined $h);1132 $date=Date_SetTime($date,$h,$mn,$s) if (defined $h); 1243 1133 last PARSE; 1244 1134 … … 1272 1162 # now week (British date: 1 week from now) 1273 1163 # today week (British date: 1 week from today) 1274 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1275 $date= &DateCalc_DateDelta($Curr{$tmp},"+0:0:1:0:0:0:0",\$err,0);1276 $date= &Date_SetTime($date,$h,$mn,$s) if ($time);1164 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1165 $date=_DateCalc_DateDelta($Curr{$tmp},"+0:0:1:0:0:0:0",\$err,0); 1166 $date=Date_SetTime($date,$h,$mn,$s) if ($time); 1277 1167 last PARSE; 1278 1168 } elsif (/^$offset\s*$wkabb$/i) { 1279 1169 # tomorrow week (British date: 1 week from tomorrow) 1280 1170 ($offset)=($1); 1281 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1171 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1282 1172 $offset=$Lang{$L}{"OffsetH"}{lc($offset)}; 1283 $date= &DateCalc_DateDelta($Curr{"Now"},$offset,\$err,0);1284 $date= &DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0);1173 $date=_DateCalc_DateDelta($Curr{"Now"},$offset,\$err,0); 1174 $date=_DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0); 1285 1175 if ($time) { 1286 1176 return "" 1287 if ( &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));1288 $date= &Date_SetTime($date,$h,$mn,$s);1177 if (_Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk)); 1178 $date=Date_SetTime($date,$h,$mn,$s); 1289 1179 } 1290 1180 last PARSE; … … 1292 1182 1293 1183 if ($tmp) { 1294 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1295 $date= &DateCalc_DateDelta($Curr{"Now"},1184 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1185 $date=_DateCalc_DateDelta($Curr{"Now"}, 1296 1186 $tmp . "0:0:$num:0:0:0:0",\$err,0); 1297 $date= &Date_GetPrev($date,$Cnf{"FirstDay"},1);1298 $date= &Date_GetNext($date,$dofw,1,$h,$mn,$s);1187 $date=Date_GetPrev($date,$Cnf{"FirstDay"},1); 1188 $date=Date_GetNext($date,$dofw,1,$h,$mn,$s); 1299 1189 last PARSE; 1300 1190 } … … 1323 1213 $y=$Curr{"Y"} if (! $y); 1324 1214 $y--; # previous year 1325 $tmp= &Date_GetNext("$y-12-31",$dofw,0);1215 $tmp=Date_GetNext("$y-12-31",$dofw,0); 1326 1216 if ($which>1) { 1327 $tmp= &DateCalc_DateDelta($tmp,"+0:0:".($which-1).":0:0:0:0",\$err,0);1217 $tmp=_DateCalc_DateDelta($tmp,"+0:0:".($which-1).":0:0:0:0",\$err,0); 1328 1218 } 1329 ($y,$m,$d)=( &Date_Split($tmp, 1))[0..2];1219 ($y,$m,$d)=(_Date_Split($tmp, 1))[0..2]; 1330 1220 last PARSE; 1331 1221 } elsif (/^$week$wkabb\s*$D(?:$of?\s*$YY)?$/i || … … 1334 1224 # sunday 22nd week in 1996 1335 1225 ($dofw,$which,$y)=($1,$2,$3); 1336 ($y,$m,$d)= &Date_NthWeekOfYear($y,$which,$dofw);1226 ($y,$m,$d)=_Date_NthWeekOfYear($y,$which,$dofw); 1337 1227 last PARSE; 1338 1228 } … … 1405 1295 } elsif (/^epochNEGATIVE (\d+)$/) { 1406 1296 $s=$1; 1407 $date= &DateCalc("1970-01-01 00:00 GMT","-0:0:$s");1297 $date=DateCalc("1970-01-01 00:00 GMT","-0:0:$s"); 1408 1298 } elsif (/^epoch\s*(\d+)$/i) { 1409 1299 $s=$1; 1410 $date= &DateCalc("1970-01-01 00:00 GMT","+0:0:$s");1300 $date=DateCalc("1970-01-01 00:00 GMT","+0:0:$s"); 1411 1301 1412 1302 } elsif ( (/^$now$/i && ($tmp="Now")) || 1413 1303 (/^$today$/i && ($tmp="Today")) ) { 1414 1304 # now, today 1415 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1305 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1416 1306 $date=$Curr{$tmp}; 1417 1307 if ($time) { 1418 1308 return "" 1419 if ( &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));1420 $date= &Date_SetTime($date,$h,$mn,$s);1309 if (_Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk)); 1310 $date=Date_SetTime($date,$h,$mn,$s); 1421 1311 } 1422 1312 last PARSE; … … 1425 1315 # yesterday, tomorrow 1426 1316 ($offset)=($1); 1427 &Date_Init() if (! $Cnf{"UpdateCurrTZ"});1317 Date_Init() if (! $Cnf{"UpdateCurrTZ"}); 1428 1318 $offset=$Lang{$L}{"OffsetH"}{lc($offset)}; 1429 $date= &DateCalc_DateDelta($Curr{"Now"},$offset,\$err,0);1319 $date=_DateCalc_DateDelta($Curr{"Now"},$offset,\$err,0); 1430 1320 if ($time) { 1431 1321 return "" 1432 if ( &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));1433 $date= &Date_SetTime($date,$h,$mn,$s);1322 if (_Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk)); 1323 $date=Date_SetTime($date,$h,$mn,$s); 1434 1324 } 1435 1325 last PARSE; … … 1442 1332 1443 1333 if (! $date) { 1444 return "" if ( &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));1445 $date= &Date_Join($y,$m,$d,$h,$mn,$s);1446 } 1447 $date= &Date_ConvTZ($date,$z);1334 return "" if (_Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk)); 1335 $date=_Date_Join($y,$m,$d,$h,$mn,$s); 1336 } 1337 $date=Date_ConvTZ($date,$z); 1448 1338 if ($midnight) { 1449 $date= &DateCalc_DateDelta($date,"+0:0:0:1:0:0:0");1339 $date=_DateCalc_DateDelta($date,"+0:0:0:1:0:0:0"); 1450 1340 } 1451 1341 return $date; … … 1454 1344 sub ParseDate { 1455 1345 print "DEBUG: ParseDate\n" if ($Curr{"Debug"} =~ /trace/); 1456 &Date_Init() if (! $Curr{"InitDone"});1346 Date_Init() if (! $Curr{"InitDone"}); 1457 1347 my($args,@args,@a,$ref,$date)=(); 1458 1348 @a=@_; … … 1469 1359 $ref=ref $args; 1470 1360 if (! $ref) { 1471 return $args if ( &Date_Split($args));1361 return $args if (_Date_Split($args)); 1472 1362 @args=($args); 1473 1363 } elsif ($ref eq "ARRAY") { 1474 1364 @args=@$args; 1475 1365 } elsif ($ref eq "SCALAR") { 1476 return $$args if ( &Date_Split($$args));1366 return $$args if (_Date_Split($$args)); 1477 1367 @args=($$args); 1478 1368 } else { … … 1490 1380 PARSE: while($#a>=0) { 1491 1381 $date=join(" ",@a); 1492 $date= &ParseDateString($date);1382 $date=ParseDateString($date); 1493 1383 last if ($date); 1494 1384 pop(@a); … … 1502 1392 sub Date_Cmp { 1503 1393 my($D1,$D2)=@_; 1504 my($date1)= &ParseDateString($D1);1505 my($date2)= &ParseDateString($D2);1394 my($date1)=ParseDateString($D1); 1395 my($date2)=ParseDateString($D2); 1506 1396 return $date1 cmp $date2; 1507 1397 } … … 1548 1438 $Curr{"InCalc"}=1; 1549 1439 1550 if ($tmp= &ParseDateString($D1)) {1440 if ($tmp=ParseDateString($D1)) { 1551 1441 # If we've already parsed the date, we don't want to do it a second 1552 1442 # time (so we don't convert timezones twice). 1553 if ( &Date_Split($D1)) {1443 if (_Date_Split($D1)) { 1554 1444 push(@date,$D1); 1555 1445 } else { 1556 1446 push(@date,$tmp); 1557 1447 } 1558 } elsif ($tmp= &ParseDateDelta($D1)) {1448 } elsif ($tmp=ParseDateDelta($D1)) { 1559 1449 push(@delta,$tmp); 1560 1450 } else { … … 1565 1455 } 1566 1456 1567 if ($tmp= &ParseDateString($D2)) {1568 if ( &Date_Split($D2)) {1457 if ($tmp=ParseDateString($D2)) { 1458 if (_Date_Split($D2)) { 1569 1459 push(@date,$D2); 1570 1460 } else { 1571 1461 push(@date,$tmp); 1572 1462 } 1573 } elsif ($tmp= &ParseDateDelta($D2)) {1463 } elsif ($tmp=ParseDateDelta($D2)) { 1574 1464 push(@delta,$tmp); 1575 1465 $mode = $Curr{"Mode"}; … … 1585 1475 1586 1476 if ($#date==1) { 1587 $ret= &DateCalc_DateDate(@date,$mode);1477 $ret=_DateCalc_DateDate(@date,$mode); 1588 1478 } elsif ($#date==0) { 1589 $ret= &DateCalc_DateDelta(@date,@delta,\$err,$mode);1479 $ret=_DateCalc_DateDelta(@date,@delta,\$err,$mode); 1590 1480 $$errref=$err if ($ref); 1591 1481 } else { 1592 $ret= &DateCalc_DeltaDelta(@delta,$mode);1482 $ret=_DateCalc_DeltaDelta(@delta,$mode); 1593 1483 } 1594 1484 $ret; … … 1634 1524 my($workweek)=$Cnf{"WorkWeekEnd"}-$Cnf{"WorkWeekBeg"}+1; 1635 1525 1636 &Date_Init() if (! $Curr{"InitDone"});1526 Date_Init() if (! $Curr{"InitDone"}); 1637 1527 # A sign can be a sequence of zero or more + and - signs, this 1638 1528 # allows for deltas like '+ -2 days'. … … 1790 1680 } 1791 1681 1792 $delta= &Delta_Normalize($delta,$Curr{"Mode"});1682 $delta=_Delta_Normalize($delta,$Curr{"Mode"}); 1793 1683 return $delta; 1794 1684 } … … 1800 1690 my($format,%f,$out,@out,$c,$date1,$date2,$tmp)=(); 1801 1691 my($scalar)=(); 1802 $date= &ParseDateString($date);1692 $date=ParseDateString($date); 1803 1693 return if (! $date); 1804 1694 1805 1695 my($y,$m,$d,$h,$mn,$s)=($f{"Y"},$f{"m"},$f{"d"},$f{"H"},$f{"M"},$f{"S"})= 1806 &Date_Split($date, 1);1696 _Date_Split($date, 1); 1807 1697 $f{"y"}=substr $f{"Y"},2; 1808 &Date_Init() if (! $Curr{"InitDone"});1698 Date_Init() if (! $Curr{"InitDone"}); 1809 1699 1810 1700 if (! wantarray) { … … 1822 1712 s/^0/ /; 1823 1713 $f{"f"}=$_; 1824 $f{"U"}= &Date_WeekOfYear($m,$d,$y,7);1825 $f{"W"}= &Date_WeekOfYear($m,$d,$y,1);1714 $f{"U"}=Date_WeekOfYear($m,$d,$y,7); 1715 $f{"W"}=Date_WeekOfYear($m,$d,$y,1); 1826 1716 1827 1717 # check week 52,53 and 0 … … 1834 1724 $mm=1; 1835 1725 $yy++; 1836 if ( &Date_WeekOfYear($mm,$dd,$yy,1)==2) {1726 if (Date_WeekOfYear($mm,$dd,$yy,1)==2) { 1837 1727 $f{"G"}=$yy; 1838 1728 $f{"W"}=1; 1839 1729 } 1840 if ( &Date_WeekOfYear($mm,$dd,$yy,7)==2) {1730 if (Date_WeekOfYear($mm,$dd,$yy,7)==2) { 1841 1731 $f{"L"}=$yy; 1842 1732 $f{"U"}=1; … … 1851 1741 $mm=12; 1852 1742 $f{"G"}=$yy; 1853 $f{"W"}= &Date_WeekOfYear($mm,$dd,$yy,1)+1;1743 $f{"W"}=Date_WeekOfYear($mm,$dd,$yy,1)+1; 1854 1744 } 1855 1745 if ($f{"U"}==0) { … … 1860 1750 $mm=12; 1861 1751 $f{"L"}=$yy; 1862 $f{"U"}= &Date_WeekOfYear($mm,$dd,$yy,7)+1;1752 $f{"U"}=Date_WeekOfYear($mm,$dd,$yy,7)+1; 1863 1753 } 1864 1754 … … 1867 1757 1868 1758 # day 1869 $f{"j"}= &Date_DayOfYear($m,$d,$y);1759 $f{"j"}=Date_DayOfYear($m,$d,$y); 1870 1760 $f{"j"} = "0" . $f{"j"} while (length($f{"j"})<3); 1871 1761 $_=$d; 1872 1762 s/^0/ /; 1873 1763 $f{"e"}=$_; 1874 $f{"w"}= &Date_DayOfWeek($m,$d,$y);1764 $f{"w"}=Date_DayOfWeek($m,$d,$y); 1875 1765 $f{"v"}=$Lang{$Cnf{"Language"}}{"WL"}[$f{"w"}-1]; 1876 1766 $f{"v"}=" ".$f{"v"} if (length $f{"v"} < 2); 1877 1767 $f{"a"}=$Lang{$Cnf{"Language"}}{"WkL"}[$f{"w"}-1]; 1878 1768 $f{"A"}=$Lang{$Cnf{"Language"}}{"WeekL"}[$f{"w"}-1]; 1879 $f{"E"}= &Date_DaySuffix($f{"e"});1769 $f{"E"}=Date_DaySuffix($f{"e"}); 1880 1770 1881 1771 # hour … … 1895 1785 1896 1786 # minute, second, timezone 1897 $f{"o"}= &Date_SecsSince1970($m,$d,$y,$h,$mn,$s);1898 $f{"s"}= &Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s);1787 $f{"o"}=Date_SecsSince1970($m,$d,$y,$h,$mn,$s); 1788 $f{"s"}=Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s); 1899 1789 $f{"Z"}=($Cnf{"ConvTZ"} eq "IGNORE" or $Cnf{"ConvTZ"} eq "") ? 1900 1790 $Cnf{"TZ"} : $Cnf{"ConvTZ"}; … … 1919 1809 if ($f{"W"}==0) { 1920 1810 $y--; 1921 $tmp= &Date_WeekOfYear(12,31,$y,1);1811 $tmp=Date_WeekOfYear(12,31,$y,1); 1922 1812 $tmp="0$tmp" if (length($tmp) < 2); 1923 1813 $f{"J"}=qq|$y-W$tmp-$f{"w"}|; … … 1945 1835 $c=chop($format); 1946 1836 if ($c eq "l") { 1947 &Date_Init();1948 $date1= &DateCalc_DateDelta($Curr{"Now"},"-0:6:0:0:0:0:0");1949 $date2= &DateCalc_DateDelta($Curr{"Now"},"+0:6:0:0:0:0:0");1950 if ( &Date_Cmp($date,$date1)>=0 && &Date_Cmp($date,$date2)<=0) {1837 Date_Init(); 1838 $date1=_DateCalc_DateDelta($Curr{"Now"},"-0:6:0:0:0:0:0"); 1839 $date2=_DateCalc_DateDelta($Curr{"Now"},"+0:6:0:0:0:0:0"); 1840 if (Date_Cmp($date,$date1)>=0 && Date_Cmp($date,$date2)<=0) { 1951 1841 $f{"l"}=qq|$f{"b"} $f{"e"} $h:$mn|; 1952 1842 } else { … … 1986 1876 my($dec,@format) = @arg; 1987 1877 1988 $delta= &ParseDateDelta($delta);1878 $delta=ParseDateDelta($delta); 1989 1879 return "" if (! $delta); 1990 1880 my(@out,%f,$out,$c1,$c2,$scalar,$format)=(); 1991 1881 local($_)=$delta; 1992 my($y,$M,$w,$d,$h,$m,$s)= &Delta_Split($delta);1882 my($y,$M,$w,$d,$h,$m,$s)=_Delta_Split($delta); 1993 1883 # Get rid of positive signs. 1994 1884 ($y,$M,$w,$d,$h,$m,$s)=map { 1*$_; }($y,$M,$w,$d,$h,$m,$s); … … 2119 2009 sub ParseRecur { 2120 2010 print "DEBUG: ParseRecur\n" if ($Curr{"Debug"} =~ /trace/); 2121 &Date_Init() if (! $Curr{"InitDone"});2011 Date_Init() if (! $Curr{"InitDone"}); 2122 2012 2123 2013 my($recur,$dateb,$date0,$date1,$flag)=@_; … … 2157 2047 2158 2048 if ($dateb) { 2159 $dateb= &ParseDateString($dateb);2049 $dateb=ParseDateString($dateb); 2160 2050 return "" if (! $dateb); 2161 2051 } 2162 2052 if ($date0) { 2163 $date0= &ParseDateString($date0);2053 $date0=ParseDateString($date0); 2164 2054 return "" if (! $date0); 2165 2055 } 2166 2056 if ($date1) { 2167 $date1= &ParseDateString($date1);2057 $date1=ParseDateString($date1); 2168 2058 return "" if (! $date1); 2169 2059 } … … 2174 2064 # 2175 2065 2176 @tmp= &Recur_Split($_);2066 @tmp=_Recur_Split($_); 2177 2067 2178 2068 if (@tmp) { … … 2190 2080 2191 2081 if ($date_b) { 2192 $date_b= &ParseDateString($date_b);2082 $date_b=ParseDateString($date_b); 2193 2083 return "" if (! $date_b); 2194 2084 } 2195 2085 if ($date_0) { 2196 $date_0= &ParseDateString($date_0);2086 $date_0=ParseDateString($date_0); 2197 2087 return "" if (! $date_0); 2198 2088 } 2199 2089 if ($date_1) { 2200 $date_1= &ParseDateString($date_1);2090 $date_1=ParseDateString($date_1); 2201 2091 return "" if (! $date_1); 2202 2092 } … … 2251 2141 if ($m) { 2252 2142 $m=$mmm{lc($m)}; 2253 $date_0= &Date_Join($y,$m,1,0,0,0);2254 $date_1= &DateCalc_DateDelta($date_0,"+0:1:0:0:0:0:0",0);2143 $date_0=_Date_Join($y,$m,1,0,0,0); 2144 $date_1=_DateCalc_DateDelta($date_0,"+0:1:0:0:0:0:0",0); 2255 2145 } else { 2256 $date_0= &Date_Join($y, 1,1,0,0,0);2257 $date_1= &Date_Join($y+1,1,1,0,0,0);2146 $date_0=_Date_Join($y, 1,1,0,0,0); 2147 $date_1=_Date_Join($y+1,1,1,0,0,0); 2258 2148 } 2259 $date_b= &DateCalc($date_0,"-0:0:0:1:0:0:0",0);2149 $date_b=DateCalc($date_0,"-0:0:0:1:0:0:0",0); 2260 2150 @recur0=(0,0,0,$num,0,0,0); 2261 2151 @recur1=(); … … 2266 2156 $y=$Curr{"Y"} if (! $y); 2267 2157 2268 $date_0= &Date_Join($y, 1,1,0,0,0);2269 $date_1= &Date_Join($y+1,1,1,0,0,0);2158 $date_0=_Date_Join($y, 1,1,0,0,0); 2159 $date_1=_Date_Join($y+1,1,1,0,0,0); 2270 2160 $date_b=$date_0; 2271 2161 … … 2282 2172 $num=-1 if ($num !~ /^$D$/); 2283 2173 2284 $date_0= &Date_Join($y,1,1,0,0,0);2285 $date_1= &Date_Join($y+1,1,1,0,0,0);2174 $date_0=_Date_Join($y,1,1,0,0,0); 2175 $date_1=_Date_Join($y+1,1,1,0,0,0); 2286 2176 $date_b=$date_0; 2287 2177 … … 2301 2191 if ($m) { 2302 2192 $m=$mmm{lc($m)}; 2303 $date_0= &Date_Join($y,$m,1,0,0,0);2304 $date_1= &DateCalc_DateDelta($date_0,"+0:1:0:0:0:0:0",0);2193 $date_0=_Date_Join($y,$m,1,0,0,0); 2194 $date_1=_DateCalc_DateDelta($date_0,"+0:1:0:0:0:0:0",0); 2305 2195 } else { 2306 $date_0= &Date_Join($y,1,1,0,0,0);2307 $date_1= &Date_Join($y+1,1,1,0,0,0);2196 $date_0=_Date_Join($y,1,1,0,0,0); 2197 $date_1=_Date_Join($y+1,1,1,0,0,0); 2308 2198 } 2309 $date_b= &DateCalc($date_0,"-0:0:0:1:0:0:0",0);2199 $date_b=DateCalc($date_0,"-0:0:0:1:0:0:0",0); 2310 2200 2311 2201 @recur0=(0,0,$num); … … 2395 2285 # Y-M-W-D-H-MN-S 2396 2286 2397 @y= &ReturnList($y);2287 @y=_ReturnList($y); 2398 2288 foreach $y (@y) { 2399 $y= &Date_FixYear($y) if (length($y)==2);2400 return () if (length($y)!=4 || ! &IsInt($y));2289 $y=_Date_FixYear($y) if (length($y)==2); 2290 return () if (length($y)!=4 || ! _IsInt($y)); 2401 2291 } 2402 2292 2403 $date0= &ParseDate("0000-01-01") if (! $date0);2404 $date1= &ParseDate("9999-12-31 23:59:59") if (! $date1);2293 $date0=ParseDate("0000-01-01") if (! $date0); 2294 $date1=ParseDate("9999-12-31 23:59:59") if (! $date1); 2405 2295 2406 2296 if ($m eq "0" and $w eq "0") { … … 2412 2302 @d=(1); 2413 2303 } else { 2414 @d= &ReturnList($d);2304 @d=_ReturnList($d); 2415 2305 return () if (! @d); 2416 2306 foreach $d (@d) { 2417 return () if (! &IsInt($d,-366,366) || $d==0);2307 return () if (! _IsInt($d,-366,366) || $d==0); 2418 2308 } 2419 2309 } … … 2421 2311 @date=(); 2422 2312 foreach $yy (@y) { 2423 my $diy = &Date_DaysInYear($yy);2313 my $diy = Date_DaysInYear($yy); 2424 2314 foreach $d (@d) { 2425 2315 my $tmpd = $d; 2426 2316 $tmpd += ($diy+1) if ($tmpd < 0); 2427 next if (! &IsInt($tmpd,1,$diy));2428 ($y,$m,$dd)= &Date_NthDayOfYear($yy,$tmpd);2429 push(@date, &Date_Join($y,$m,$dd,0,0,0));2317 next if (! _IsInt($tmpd,1,$diy)); 2318 ($y,$m,$dd)=Date_NthDayOfYear($yy,$tmpd); 2319 push(@date, _Date_Join($y,$m,$dd,0,0,0)); 2430 2320 } 2431 2321 } … … 2437 2327 # * Y-M-0-DOM-H-MN-S 2438 2328 2439 @m= &ReturnList($m);2329 @m=_ReturnList($m); 2440 2330 return () if (! @m); 2441 2331 foreach $m (@m) { 2442 return () if (! &IsInt($m,1,12));2332 return () if (! _IsInt($m,1,12)); 2443 2333 } 2444 2334 … … 2446 2336 @d=(1); 2447 2337 } else { 2448 @d= &ReturnList($d);2338 @d=_ReturnList($d); 2449 2339 return () if (! @d); 2450 2340 foreach $d (@d) { 2451 return () if (! &IsInt($d,-31,31) || $d==0);2341 return () if (! _IsInt($d,-31,31) || $d==0); 2452 2342 } 2453 2343 } … … 2456 2346 foreach $y (@y) { 2457 2347 foreach $m (@m) { 2458 my $dim = &Date_DaysInMonth($m,$y);2348 my $dim = Date_DaysInMonth($m,$y); 2459 2349 foreach $d (@d) { 2460 2350 my $tmpd = $d; 2461 2351 $tmpd += ($dim+1) if ($d<0); 2462 next if (! &IsInt($tmpd,1,$dim));2463 $date= &Date_Join($y,$m,$tmpd,0,0,0);2352 next if (! _IsInt($tmpd,1,$dim)); 2353 $date=_Date_Join($y,$m,$tmpd,0,0,0); 2464 2354 push(@date,$date); 2465 2355 } … … 2473 2363 # * Y-0-WOY-0-H-MN-S 2474 2364 2475 @w= &ReturnList($w);2365 @w=_ReturnList($w); 2476 2366 return () if (! @w); 2477 2367 foreach $w (@w) { 2478 return () if (! &IsInt($w,-53,53) || $w==0);2368 return () if (! _IsInt($w,-53,53) || $w==0); 2479 2369 } 2480 2370 … … 2482 2372 @d=(1); 2483 2373 } else { 2484 @d= &ReturnList($d);2374 @d=_ReturnList($d); 2485 2375 return () if (! @d); 2486 2376 foreach $d (@d) { 2487 2377 $d += 8 if ($d<0); 2488 return () if (! &IsInt($d,1,7));2378 return () if (! _IsInt($d,1,7)); 2489 2379 } 2490 2380 } … … 2506 2396 $date=Date_GetNext($date,$d,1); 2507 2397 } 2508 $date= &DateCalc_DateDelta($date,$del);2509 push(@date,$date) if ( ( &Date_Split($date))[0] == $y);2398 $date=_DateCalc_DateDelta($date,$del); 2399 push(@date,$date) if ( (_Date_Split($date))[0] == $y); 2510 2400 } 2511 2401 } … … 2518 2408 # * Y-M-WOM-0-H-MN-S 2519 2409 2520 @m= &ReturnList($m);2410 @m=_ReturnList($m); 2521 2411 return () if (! @m); 2522 @w= &ReturnList($w);2412 @w=_ReturnList($w); 2523 2413 return () if (! @w); 2524 2414 if ($d eq "0") { 2525 2415 @d=(1); 2526 2416 } else { 2527 @d= &ReturnList($d);2417 @d=_ReturnList($d); 2528 2418 } 2529 2419 2530 @date= &Date_Recur_WoM(\@y,\@m,\@w,\@d);2420 @date=_Date_Recur_WoM(\@y,\@m,\@w,\@d); 2531 2421 last RECUR; 2532 2422 } … … 2550 2440 return () if (! $dateb && $y != 1); 2551 2441 2552 @m= &ReturnList($m);2442 @m=_ReturnList($m); 2553 2443 return () if (! @m); 2554 2444 foreach $m (@m) { 2555 return () if (! &IsInt($m,1,12));2445 return () if (! _IsInt($m,1,12)); 2556 2446 } 2557 2447 … … 2559 2449 @d = (1); 2560 2450 } else { 2561 @d= &ReturnList($d);2451 @d=_ReturnList($d); 2562 2452 return () if (! @d); 2563 2453 foreach $d (@d) { 2564 return () if (! &IsInt($d,-31,31) || $d==0);2454 return () if (! _IsInt($d,-31,31) || $d==0); 2565 2455 } 2566 2456 } 2567 2457 2568 2458 # We need to find years that are a multiple of $n from $y(base) 2569 ($y0)=( &Date_Split($date0, 1) )[0];2570 ($y1)=( &Date_Split($date1, 1) )[0];2459 ($y0)=( _Date_Split($date0, 1) )[0]; 2460 ($y1)=( _Date_Split($date1, 1) )[0]; 2571 2461 if ($dateb) { 2572 ($yb)=( &Date_Split($dateb, 1) )[0];2462 ($yb)=( _Date_Split($dateb, 1) )[0]; 2573 2463 } else { 2574 2464 # If $y=1, there is no base year … … 2581 2471 foreach $m (@m) { 2582 2472 foreach $d (@d) { 2583 my $dim = &Date_DaysInMonth($m,$yy);2473 my $dim = Date_DaysInMonth($m,$yy); 2584 2474 my $tmpd = $d; 2585 2475 if ($tmpd < 0) { 2586 2476 $tmpd += ($dim+1); 2587 2477 } 2588 next if (! &IsInt($tmpd,1,$dim));2589 $date= &Date_Join($yy,$m,$tmpd,0,0,0);2478 next if (! _IsInt($tmpd,1,$dim)); 2479 $date=_Date_Join($yy,$m,$tmpd,0,0,0); 2590 2480 push(@date,$date); 2591 2481 } … … 2601 2491 return () if (! $dateb && $y != 1); 2602 2492 2603 @m= &ReturnList($m);2493 @m=_ReturnList($m); 2604 2494 return () if (! @m); 2605 @w= &ReturnList($w);2495 @w=_ReturnList($w); 2606 2496 return () if (! @w); 2607 2497 … … 2609 2499 @d=(1); 2610 2500 } else { 2611 @d= &ReturnList($d);2501 @d=_ReturnList($d); 2612 2502 } 2613 2503 2614 ($y0)=( &Date_Split($date0, 1) )[0];2615 ($y1)=( &Date_Split($date1, 1) )[0];2504 ($y0)=( _Date_Split($date0, 1) )[0]; 2505 ($y1)=( _Date_Split($date1, 1) )[0]; 2616 2506 if ($dateb) { 2617 ($yb)=( &Date_Split($dateb, 1) )[0];2507 ($yb)=( _Date_Split($dateb, 1) )[0]; 2618 2508 } else { 2619 2509 # If $y=1, there is no base year … … 2627 2517 } 2628 2518 2629 @date= &Date_Recur_WoM(\@y,\@m,\@w,\@d);2519 @date=_Date_Recur_WoM(\@y,\@m,\@w,\@d); 2630 2520 last RECUR; 2631 2521 } … … 2649 2539 $n=1 if ($n==0); 2650 2540 2651 @w= &ReturnList($w);2541 @w=_ReturnList($w); 2652 2542 return () if (! @w); 2653 2543 foreach $w (@w) { 2654 return () if ($w==0 || ! &IsInt($w,-53,53));2544 return () if ($w==0 || ! _IsInt($w,-53,53)); 2655 2545 } 2656 2546 … … 2658 2548 @d=(1); 2659 2549 } else { 2660 @d= &ReturnList($d);2550 @d=_ReturnList($d); 2661 2551 return () if (! @d); 2662 2552 foreach $d (@d) { 2663 2553 $d += 8 if ($d<0); 2664 return () if (! &IsInt($d,1,7));2554 return () if (! _IsInt($d,1,7)); 2665 2555 } 2666 2556 } 2667 2557 2668 2558 # We need to find years that are a multiple of $n from $y(base) 2669 ($y0)=( &Date_Split($date0, 1) )[0];2670 ($y1)=( &Date_Split($date1, 1) )[0];2559 ($y0)=( _Date_Split($date0, 1) )[0]; 2560 ($y1)=( _Date_Split($date1, 1) )[0]; 2671 2561 if ($dateb) { 2672 ($yb)=( &Date_Split($dateb, 1) )[0];2562 ($yb)=( _Date_Split($dateb, 1) )[0]; 2673 2563 } else { 2674 2564 # If $y=1, there is no base year … … 2693 2583 $date=Date_GetNext($date,$d,1); 2694 2584 } 2695 $date= &DateCalc($date,$del);2696 next if (( &Date_Split($date))[0] != $yy);2585 $date=DateCalc($date,$del); 2586 next if ((_Date_Split($date))[0] != $yy); 2697 2587 push(@date,$date); 2698 2588 } … … 2706 2596 # Y-M * WOM-0-H-MN-S 2707 2597 # Y-M * WOM-DOW-H-MN-S 2708 return () if (! $dateb );2598 return () if (! $dateb && ($y != 0 || $m != 1)); 2709 2599 @tmp=(@recur0); 2710 2600 push(@tmp,0) while ($#tmp<6); 2711 2601 $delta=join(":",@tmp); 2712 @tmp=&Date_Recur($date0,$date1,$dateb,$delta); 2713 2714 @w=&ReturnList($w); 2602 $dateb=$date0 if (! $dateb); 2603 @tmp=_Date_Recur($date0,$date1,$dateb,$delta); 2604 2605 @w=_ReturnList($w); 2715 2606 @m=(); 2716 2607 if ($d eq "0") { 2717 2608 @d=(1); 2718 2609 } else { 2719 @d= &ReturnList($d);2610 @d=_ReturnList($d); 2720 2611 } 2721 2612 2722 @date= &Date_Recur_WoM(\@tmp,\@m,\@w,\@d);2613 @date=_Date_Recur_WoM(\@tmp,\@m,\@w,\@d); 2723 2614 last RECUR; 2724 2615 } … … 2734 2625 $y=1 if ($y==0 && $m==0 && $w==0); 2735 2626 $delta="$y:$m:$w:0:0:0:0"; 2736 @date= &Date_Recur($date0,$date1,$dateb,$delta);2627 @date=_Date_Recur($date0,$date1,$dateb,$delta); 2737 2628 last RECUR; 2738 2629 … … 2744 2635 return () if (! $dateb && $y!=1); 2745 2636 2746 @d= &ReturnList($d);2637 @d=_ReturnList($d); 2747 2638 return () if (! @d); 2748 2639 foreach $d (@d) { 2749 return () if (! &IsInt($d,-366,366) || $d==0);2640 return () if (! _IsInt($d,-366,366) || $d==0); 2750 2641 } 2751 2642 2752 2643 # We need to find years that are a multiple of $n from $y(base) 2753 ($y0)=( &Date_Split($date0, 1) )[0];2754 ($y1)=( &Date_Split($date1, 1) )[0];2644 ($y0)=( _Date_Split($date0, 1) )[0]; 2645 ($y1)=( _Date_Split($date1, 1) )[0]; 2755 2646 if ($dateb) { 2756 ($yb)=( &Date_Split($dateb, 1) )[0];2647 ($yb)=( _Date_Split($dateb, 1) )[0]; 2757 2648 } else { 2758 2649 # If $y=1, there is no base year … … 2761 2652 @date=(); 2762 2653 for ($yy=$y0; $yy<=$y1; $yy++) { 2763 my $diy = &Date_DaysInYear($yy);2654 my $diy = Date_DaysInYear($yy); 2764 2655 if (($yy-$yb)%$n == 0) { 2765 2656 foreach $d (@d) { 2766 2657 my $tmpd = $d; 2767 2658 $tmpd += ($diy+1) if ($tmpd<0); 2768 next if (! &IsInt($tmpd,1,$diy));2769 ($y,$m,$dd)= &Date_NthDayOfYear($yy,$tmpd);2770 push(@date, &Date_Join($y,$m,$dd,0,0,0));2659 next if (! _IsInt($tmpd,1,$diy)); 2660 ($y,$m,$dd)=Date_NthDayOfYear($yy,$tmpd); 2661 push(@date, _Date_Join($y,$m,$dd,0,0,0)); 2771 2662 } 2772 2663 } … … 2777 2668 2778 2669 # Y-M-W * DOW-H-MN-S 2779 return () if (! $dateb );2670 return () if (! $dateb && ($y != 0 && $m != 0 && $w != 1)); 2780 2671 @tmp=(@recur0); 2781 2672 push(@tmp,0) while ($#tmp<6); 2782 2673 $delta=join(":",@tmp); 2783 2674 2784 @d= &ReturnList($d);2675 @d=_ReturnList($d); 2785 2676 return () if (! @d); 2786 2677 foreach $d (@d) { 2787 2678 $d += 8 if ($d<0); 2788 return () if (! &IsInt($d,1,7));2679 return () if (! _IsInt($d,1,7)); 2789 2680 } 2790 2681 2791 2682 # Find out what DofW the basedate is. 2792 @tmp2=&Date_Split($dateb, 1); 2793 $tmp=&Date_DayOfWeek($tmp2[1],$tmp2[2],$tmp2[0]); 2683 $dateb = $date0 if (! $dateb); 2684 @tmp2=_Date_Split($dateb, 1); 2685 $tmp=Date_DayOfWeek($tmp2[1],$tmp2[2],$tmp2[0]); 2794 2686 2795 2687 @date=(); … … 2801 2693 ($tmp>=$Cnf{"FirstDay"} && $d>$tmp) || 2802 2694 ($tmp<$d && $d<$Cnf{"FirstDay"})) { 2803 $date_b= &Date_GetNext($date_b,$d);2695 $date_b=Date_GetNext($date_b,$d); 2804 2696 } else { 2805 $date_b= &Date_GetPrev($date_b,$d);2697 $date_b=Date_GetPrev($date_b,$d); 2806 2698 } 2807 2699 } 2808 push(@date, &Date_Recur($date0,$date1,$date_b,$delta));2700 push(@date,_Date_Recur($date0,$date1,$date_b,$delta)); 2809 2701 } 2810 2702 last RECUR; … … 2813 2705 2814 2706 # Y-M-0 * DOM-H-MN-S 2815 return () if (! $dateb );2707 return () if (! $dateb && ($y != 0 && $m != 1)); 2816 2708 @tmp=(@recur0); 2817 2709 push(@tmp,0) while ($#tmp<6); 2818 2710 $delta=join(":",@tmp); 2819 2711 2820 @d= &ReturnList($d);2712 @d=_ReturnList($d); 2821 2713 return () if (! @d); 2822 2714 foreach $d (@d) { 2823 return () if ($d==0 || ! &IsInt($d,-31,31));2715 return () if ($d==0 || ! _IsInt($d,-31,31)); 2824 2716 } 2825 2826 @tmp2=&Date_Recur($date0,$date1,$dateb,$delta); 2717 $dateb = $date0 if (! $dateb); 2718 2719 @tmp2=_Date_Recur($date0,$date1,$dateb,$delta); 2827 2720 @date=(); 2828 2721 foreach $date (@tmp2) { 2829 ($y,$m)=( &Date_Split($date, 1) )[0..1];2830 my $dim= &Date_DaysInMonth($m,$y);2722 ($y,$m)=( _Date_Split($date, 1) )[0..1]; 2723 my $dim=Date_DaysInMonth($m,$y); 2831 2724 foreach $d (@d) { 2832 2725 my $tmpd = $d; 2833 2726 $tmpd += ($dim+1) if ($tmpd<0); 2834 next if (! &IsInt($tmpd,1,$dim));2835 push(@date, &Date_Join($y,$m,$tmpd,0,0,0));2727 next if (! _IsInt($tmpd,1,$dim)); 2728 push(@date,_Date_Join($y,$m,$tmpd,0,0,0)); 2836 2729 } 2837 2730 } … … 2849 2742 # Y-M-W-D-H-MN * S 2850 2743 # Y-M-W-D-H-S 2744 if (($#recur0 == 3 && 2745 ($y == 0 && $m == 0 && $w == 0 && $d == 1)) || 2746 ($#recur0 == 4 && 2747 ($y == 0 && $m == 0 && $w == 0 && $d == 0 && $h == 1)) || 2748 ($#recur0 == 5 && 2749 ($y == 0 && $m == 0 && $w == 0 && $d == 0 && $h == 0 && 2750 $mn == 1))) { 2751 $dateb = $date0; 2752 } 2851 2753 return () if (! $dateb); 2852 2754 @tmp=(@recur0); … … 2854 2756 $delta=join(":",@tmp); 2855 2757 return () if ($delta !~ /[1-9]/); # return if "0:0:0:0:0:0:0" 2856 @date= &Date_Recur($date0,$date1,$dateb,$delta);2758 @date=_Date_Recur($date0,$date1,$dateb,$delta); 2857 2759 if (@recur1) { 2858 2760 unshift(@recur1,-1) while ($#recur1<2); … … 2867 2769 last RECUR; 2868 2770 } 2869 @date= &Date_RecurSetTime($date0,$date1,\@date,@time) if (@time);2771 @date=_Date_RecurSetTime($date0,$date1,\@date,@time) if (@time); 2870 2772 2871 2773 # … … 2886 2788 foreach $date (@date) { 2887 2789 if ($forw) { 2888 push(@tmp, &Date_GetNext($date,$d,$today));2790 push(@tmp, Date_GetNext($date,$d,$today)); 2889 2791 } else { 2890 push(@tmp, &Date_GetPrev($date,$d,$today));2792 push(@tmp, Date_GetPrev($date,$d,$today)); 2891 2793 } 2892 2794 } … … 2909 2811 for ($i=1; $i<=$n; $i++) { 2910 2812 while (1) { 2911 $date= &DateCalc($date,"${sign}0:0:0:1:0:0:0");2912 last if (! $work || &Date_IsWorkDay($date,0));2813 $date=DateCalc($date,"${sign}0:0:0:1:0:0:0"); 2814 last if (! $work || Date_IsWorkDay($date,0)); 2913 2815 } 2914 2816 } … … 2931 2833 DATE: foreach $date (@date) { 2932 2834 $df=$db=$date; 2933 if ( &Date_IsWorkDay($date)) {2835 if (Date_IsWorkDay($date)) { 2934 2836 push(@tmp,$date); 2935 2837 next DATE; … … 2937 2839 while (1) { 2938 2840 if ($forw) { 2939 $d=$df= &DateCalc($df,"+0:0:0:1:0:0:0");2841 $d=$df=DateCalc($df,"+0:0:0:1:0:0:0"); 2940 2842 } else { 2941 $d=$db= &DateCalc($db,"-0:0:0:1:0:0:0");2843 $d=$db=DateCalc($db,"-0:0:0:1:0:0:0"); 2942 2844 } 2943 if ( &Date_IsWorkDay($d)) {2845 if (Date_IsWorkDay($d)) { 2944 2846 push(@tmp,$d); 2945 2847 next DATE; … … 2955 2857 @tmp=(); 2956 2858 foreach $date (@date) { 2957 ($y,$m,$d,$h,$mn,$s)= &Date_Split($date, 1);2958 ($m,$d)= &Date_Easter($y);2959 $date= &Date_Join($y,$m,$d,$h,$mn,$s);2960 next if ( &Date_Cmp($date,$date0)<0 ||2961 &Date_Cmp($date,$date1)>0);2859 ($y,$m,$d,$h,$mn,$s)=_Date_Split($date, 1); 2860 ($m,$d)=_Date_Easter($y); 2861 $date=_Date_Join($y,$m,$d,$h,$mn,$s); 2862 next if (Date_Cmp($date,$date0)<0 || 2863 Date_Cmp($date,$date1)>0); 2962 2864 push(@tmp,$date); 2963 2865 } … … 2974 2876 print "DEBUG: Date_GetPrev\n" if ($Curr{"Debug"} =~ /trace/); 2975 2877 my($date,$dow,$today,$hr,$min,$sec)=@_; 2976 &Date_Init() if (! $Curr{"InitDone"});2878 Date_Init() if (! $Curr{"InitDone"}); 2977 2879 my($y,$m,$d,$h,$mn,$s,$err,$curr_dow,%dow,$num,$delta,$th,$tm,$ts, 2978 2880 $adjust,$curr)=(); … … 2981 2883 $sec="00" if (defined $sec && $sec eq "0"); 2982 2884 2983 if (! &Date_Split($date)) {2984 $date= &ParseDateString($date);2885 if (! _Date_Split($date)) { 2886 $date=ParseDateString($date); 2985 2887 return "" if (! $date); 2986 2888 } 2987 2889 $curr=$date; 2988 ($y,$m,$d)=( &Date_Split($date, 1) )[0..2];2890 ($y,$m,$d)=( _Date_Split($date, 1) )[0..2]; 2989 2891 2990 2892 if ($dow) { 2991 $curr_dow= &Date_DayOfWeek($m,$d,$y);2893 $curr_dow=Date_DayOfWeek($m,$d,$y); 2992 2894 %dow=%{ $Lang{$Cnf{"Language"}}{"WeekH"} }; 2993 if ( &IsInt($dow)) {2895 if (_IsInt($dow)) { 2994 2896 return "" if ($dow<1 || $dow>7); 2995 2897 } else { … … 2998 2900 } 2999 2901 if ($dow == $curr_dow) { 3000 $date= &DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0) if (! $today);2902 $date=_DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0) if (! $today); 3001 2903 $adjust=1 if ($today==2); 3002 2904 } else { 3003 2905 $dow -= 7 if ($dow>$curr_dow); # make sure previous day is less 3004 2906 $num = $curr_dow - $dow; 3005 $date= &DateCalc_DateDelta($date,"-0:0:0:$num:0:0:0",\$err,0);3006 } 3007 $date= &Date_SetTime($date,$hr,$min,$sec) if (defined $hr);3008 $date= &DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0)3009 if ($adjust && &Date_Cmp($date,$curr)>0);2907 $date=_DateCalc_DateDelta($date,"-0:0:0:$num:0:0:0",\$err,0); 2908 } 2909 $date=Date_SetTime($date,$hr,$min,$sec) if (defined $hr); 2910 $date=_DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0) 2911 if ($adjust && Date_Cmp($date,$curr)>0); 3010 2912 3011 2913 } else { 3012 ($h,$mn,$s)=( &Date_Split($date, 1) )[3..5];3013 ($th,$tm,$ts)= &Date_ParseTime($hr,$min,$sec);2914 ($h,$mn,$s)=( _Date_Split($date, 1) )[3..5]; 2915 ($th,$tm,$ts)=_Date_ParseTime($hr,$min,$sec); 3014 2916 if ($hr) { 3015 2917 ($hr,$min,$sec)=($th,$tm,$ts); … … 3025 2927 } 3026 2928 3027 $d= &Date_SetTime($date,$hr,$min,$sec);2929 $d=Date_SetTime($date,$hr,$min,$sec); 3028 2930 if ($today) { 3029 $d= &DateCalc_DateDelta($d,$delta,\$err,0) if (&Date_Cmp($d,$date)>0);2931 $d=_DateCalc_DateDelta($d,$delta,\$err,0) if (Date_Cmp($d,$date)>0); 3030 2932 } else { 3031 $d= &DateCalc_DateDelta($d,$delta,\$err,0) if (&Date_Cmp($d,$date)>=0);2933 $d=_DateCalc_DateDelta($d,$delta,\$err,0) if (Date_Cmp($d,$date)>=0); 3032 2934 } 3033 2935 $date=$d; … … 3039 2941 print "DEBUG: Date_GetNext\n" if ($Curr{"Debug"} =~ /trace/); 3040 2942 my($date,$dow,$today,$hr,$min,$sec)=@_; 3041 &Date_Init() if (! $Curr{"InitDone"});2943 Date_Init() if (! $Curr{"InitDone"}); 3042 2944 my($y,$m,$d,$h,$mn,$s,$err,$curr_dow,%dow,$num,$delta,$th,$tm,$ts, 3043 2945 $adjust,$curr)=(); … … 3046 2948 $sec="00" if (defined $sec && $sec eq "0"); 3047 2949 3048 if (! &Date_Split($date)) {3049 $date= &ParseDateString($date);2950 if (! _Date_Split($date)) { 2951 $date=ParseDateString($date); 3050 2952 return "" if (! $date); 3051 2953 } 3052 2954 $curr=$date; 3053 ($y,$m,$d)=( &Date_Split($date, 1) )[0..2];2955 ($y,$m,$d)=( _Date_Split($date, 1) )[0..2]; 3054 2956 3055 2957 if ($dow) { 3056 $curr_dow= &Date_DayOfWeek($m,$d,$y);2958 $curr_dow=Date_DayOfWeek($m,$d,$y); 3057 2959 %dow=%{ $Lang{$Cnf{"Language"}}{"WeekH"} }; 3058 if ( &IsInt($dow)) {2960 if (_IsInt($dow)) { 3059 2961 return "" if ($dow<1 || $dow>7); 3060 2962 } else { … … 3063 2965 } 3064 2966 if ($dow == $curr_dow) { 3065 $date= &DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0) if (! $today);2967 $date=_DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0) if (! $today); 3066 2968 $adjust=1 if ($today==2); 3067 2969 } else { 3068 2970 $curr_dow -= 7 if ($curr_dow>$dow); # make sure next date is greater 3069 2971 $num = $dow - $curr_dow; 3070 $date= &DateCalc_DateDelta($date,"+0:0:0:$num:0:0:0",\$err,0);3071 } 3072 $date= &Date_SetTime($date,$hr,$min,$sec) if (defined $hr);3073 $date= &DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0)3074 if ($adjust && &Date_Cmp($date,$curr)<0);2972 $date=_DateCalc_DateDelta($date,"+0:0:0:$num:0:0:0",\$err,0); 2973 } 2974 $date=Date_SetTime($date,$hr,$min,$sec) if (defined $hr); 2975 $date=_DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0) 2976 if ($adjust && Date_Cmp($date,$curr)<0); 3075 2977 3076 2978 } else { 3077 ($h,$mn,$s)=( &Date_Split($date, 1) )[3..5];3078 ($th,$tm,$ts)= &Date_ParseTime($hr,$min,$sec);2979 ($h,$mn,$s)=( _Date_Split($date, 1) )[3..5]; 2980 ($th,$tm,$ts)=_Date_ParseTime($hr,$min,$sec); 3079 2981 if ($hr) { 3080 2982 ($hr,$min,$sec)=($th,$tm,$ts); … … 3090 2992 } 3091 2993 3092 $d= &Date_SetTime($date,$hr,$min,$sec);2994 $d=Date_SetTime($date,$hr,$min,$sec); 3093 2995 if ($today) { 3094 $d= &DateCalc_DateDelta($d,$delta,\$err,0) if (&Date_Cmp($d,$date)<0);2996 $d=_DateCalc_DateDelta($d,$delta,\$err,0) if (Date_Cmp($d,$date)<0); 3095 2997 } else { 3096 $d= &DateCalc_DateDelta($d,$delta,\$err,0) if (&Date_Cmp($d,$date)<1);2998 $d=_DateCalc_DateDelta($d,$delta,\$err,0) if (Date_Cmp($d,$date)<1); 3097 2999 } 3098 3000 $date=$d; … … 3105 3007 print "DEBUG: Date_IsHoliday\n" if ($Curr{"Debug"} =~ /trace/); 3106 3008 my($date)=@_; 3107 &Date_Init() if (! $Curr{"InitDone"});3108 $date= &ParseDateString($date);3009 Date_Init() if (! $Curr{"InitDone"}); 3010 $date=ParseDateString($date); 3109 3011 return undef if (! $date); 3110 $date= &Date_SetTime($date,0,0,0);3111 my($y)=( &Date_Split($date, 1))[0];3112 &Date_UpdateHolidays($y) if (! exists $Holiday{"dates"}{$y});3012 $date=Date_SetTime($date,0,0,0); 3013 my($y)=(_Date_Split($date, 1))[0]; 3014 _Date_UpdateHolidays($y) if (! exists $Holiday{"dates"}{$y}); 3113 3015 return undef if (! exists $Holiday{"dates"}{$y}{$date}); 3114 3016 my($name)=$Holiday{"dates"}{$y}{$date}; … … 3120 3022 print "DEBUG: Events_List\n" if ($Curr{"Debug"} =~ /trace/); 3121 3023 my(@args)=@_; 3122 &Date_Init() if (! $Curr{"InitDone"});3123 &Events_ParseRaw();3024 Date_Init() if (! $Curr{"InitDone"}); 3025 _Events_ParseRaw(); 3124 3026 3125 3027 my($tmp,$date0,$date1,$flag); 3126 $date0= &ParseDateString($args[0]);3028 $date0=ParseDateString($args[0]); 3127 3029 warn "Invalid date $args[0]", return undef if (! $date0); 3128 3030 3129 3031 if ($#args == 0) { 3130 return &Events_Calc($date0);3032 return _Events_Calc($date0); 3131 3033 } 3132 3034 3133 3035 if ($args[1]) { 3134 $date1= &ParseDateString($args[1]);3036 $date1=ParseDateString($args[1]); 3135 3037 warn "Invalid date $args[1]\n", return undef if (! $date1); 3136 if ( &Date_Cmp($date0,$date1)>0) {3038 if (Date_Cmp($date0,$date1)>0) { 3137 3039 $tmp=$date1; 3138 3040 $date1=$date0; … … 3140 3042 } 3141 3043 } else { 3142 $date0= &Date_SetTime($date0,"00:00:00");3143 $date1= &DateCalc_DateDelta($date0,"+0:0:0:1:0:0:0");3144 } 3145 3146 $tmp= &Events_Calc($date0,$date1);3044 $date0=Date_SetTime($date0,"00:00:00"); 3045 $date1=_DateCalc_DateDelta($date0,"+0:0:0:1:0:0:0"); 3046 } 3047 3048 $tmp=_Events_Calc($date0,$date1); 3147 3049 3148 3050 $flag=$args[2]; … … 3157 3059 ($date0,$tmp)=splice(@tmp,0,2); 3158 3060 $date1=$tmp[0]; 3159 $delta= &DateCalc_DateDate($date0,$date1);3061 $delta=_DateCalc_DateDate($date0,$date1); 3160 3062 foreach $flag (@$tmp) { 3161 3063 if (exists $ret{$flag}) { 3162 $ret{$flag}= &DateCalc_DeltaDelta($ret{$flag},$delta);3064 $ret{$flag}=_DateCalc_DeltaDelta($ret{$flag},$delta); 3163 3065 } else { 3164 3066 $ret{$flag}=$delta; … … 3172 3074 ($date0,$tmp)=splice(@tmp,0,2); 3173 3075 $date1=$tmp[0]; 3174 $delta= &DateCalc_DateDate($date0,$date1);3076 $delta=_DateCalc_DateDate($date0,$date1); 3175 3077 $flag=join("+",sort { Date_Cmp($a,$b) } @$tmp); 3176 3078 next if (! $flag); 3177 3079 if (exists $ret{$flag}) { 3178 $ret{$flag}= &DateCalc_DeltaDelta($ret{$flag},$delta);3080 $ret{$flag}=_DateCalc_DeltaDelta($ret{$flag},$delta); 3179 3081 } else { 3180 3082 $ret{$flag}=$delta; … … 3195 3097 print "DEBUG: Date_SetTime\n" if ($Curr{"Debug"} =~ /trace/); 3196 3098 my($date,$h,$mn,$s)=@_; 3197 &Date_Init() if (! $Curr{"InitDone"});3099 Date_Init() if (! $Curr{"InitDone"}); 3198 3100 my($y,$m,$d)=(); 3199 3101 3200 if (! &Date_Split($date)) {3201 $date= &ParseDateString($date);3102 if (! _Date_Split($date)) { 3103 $date=ParseDateString($date); 3202 3104 return "" if (! $date); 3203 3105 } 3204 3106 3205 ($y,$m,$d)=( &Date_Split($date, 1) )[0..2];3206 ($h,$mn,$s)= &Date_ParseTime($h,$mn,$s);3107 ($y,$m,$d)=( _Date_Split($date, 1) )[0..2]; 3108 ($h,$mn,$s)=_Date_ParseTime($h,$mn,$s); 3207 3109 3208 3110 my($ampm,$wk); 3209 return "" if ( &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));3210 &Date_Join($y,$m,$d,$h,$mn,$s);3111 return "" if (_Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk)); 3112 _Date_Join($y,$m,$d,$h,$mn,$s); 3211 3113 } 3212 3114 … … 3217 3119 $nocheck=0 if (! defined $nocheck); 3218 3120 3219 ($y,$m,$d,$h,$mn,$s)= &Date_Split($date);3121 ($y,$m,$d,$h,$mn,$s)=_Date_Split($date); 3220 3122 3221 3123 if (! $y) { 3222 $date= &ParseDateString($date);3124 $date=ParseDateString($date); 3223 3125 return "" if (! $date); 3224 ($y,$m,$d,$h,$mn,$s)= &Date_Split($date, 1);3126 ($y,$m,$d,$h,$mn,$s)=_Date_Split($date, 1); 3225 3127 } 3226 3128 … … 3241 3143 } 3242 3144 3243 $date= &Date_Join($y,$m,$d,$h,$mn,$s);3244 return $date if ($nocheck || &Date_Split($date));3145 $date=_Date_Join($y,$m,$d,$h,$mn,$s); 3146 return $date if ($nocheck || _Date_Split($date)); 3245 3147 return ""; 3246 3148 } … … 3261 3163 print "DEBUG: Date_DaysInMonth\n" if ($Curr{"Debug"} =~ /trace/); 3262 3164 my($m,$y)=@_; 3263 $y= &Date_FixYear($y) if (length($y)!=4);3165 $y=_Date_FixYear($y) if (length($y)!=4); 3264 3166 my(@d_in_m)=(0,31,28,31,30,31,30,31,31,30,31,30,31); 3265 $d_in_m[2]=29 if ( &Date_LeapYear($y));3167 $d_in_m[2]=29 if (Date_LeapYear($y)); 3266 3168 return $d_in_m[$m]; 3267 3169 } … … 3270 3172 print "DEBUG: Date_DayOfWeek\n" if ($Curr{"Debug"} =~ /trace/); 3271 3173 my($m,$d,$y)=@_; 3272 $y= &Date_FixYear($y) if (length($y)!=4);3174 $y=_Date_FixYear($y) if (length($y)!=4); 3273 3175 my($dayofweek,$dec31)=(); 3274 3176 3275 3177 $dec31=5; # Dec 31, 1BC was Friday 3276 $dayofweek=( &Date_DaysSince1BC($m,$d,$y)+$dec31) % 7;3178 $dayofweek=(Date_DaysSince1BC($m,$d,$y)+$dec31) % 7; 3277 3179 $dayofweek=7 if ($dayofweek==0); 3278 3180 return $dayofweek; … … 3284 3186 print "DEBUG: Date_SecsSince1970\n" if ($Curr{"Debug"} =~ /trace/); 3285 3187 my($m,$d,$y,$h,$mn,$s)=@_; 3286 $y= &Date_FixYear($y) if (length($y)!=4);3188 $y=_Date_FixYear($y) if (length($y)!=4); 3287 3189 my($sec_now,$sec_70)=(); 3288 $sec_now=( &Date_DaysSince1BC($m,$d,$y)-1)*24*3600 + $h*3600 + $mn*60 + $s;3289 # $sec_70 =( &Date_DaysSince1BC(1,1,1970)-1)*24*3600;3190 $sec_now=(Date_DaysSince1BC($m,$d,$y)-1)*24*3600 + $h*3600 + $mn*60 + $s; 3191 # $sec_70 =(Date_DaysSince1BC(1,1,1970)-1)*24*3600; 3290 3192 $sec_70 =62167219200; 3291 3193 return ($sec_now-$sec_70); … … 3295 3197 print "DEBUG: Date_SecsSince1970GMT\n" if ($Curr{"Debug"} =~ /trace/); 3296 3198 my($m,$d,$y,$h,$mn,$s)=@_; 3297 &Date_Init() if (! $Curr{"InitDone"});3298 $y= &Date_FixYear($y) if (length($y)!=4);3299 3300 my($sec)= &Date_SecsSince1970($m,$d,$y,$h,$mn,$s);3199 Date_Init() if (! $Curr{"InitDone"}); 3200 $y=_Date_FixYear($y) if (length($y)!=4); 3201 3202 my($sec)=Date_SecsSince1970($m,$d,$y,$h,$mn,$s); 3301 3203 return $sec if ($Cnf{"ConvTZ"} eq "IGNORE"); 3302 3204 … … 3316 3218 print "DEBUG: Date_DaysSince1BC\n" if ($Curr{"Debug"} =~ /trace/); 3317 3219 my($m,$d,$y)=@_; 3318 $y= &Date_FixYear($y) if (length($y)!=4);3220 $y=_Date_FixYear($y) if (length($y)!=4); 3319 3221 my($Ny,$N4,$N100,$N400,$dayofyear,$days)=(); 3320 3222 my($cc,$yy)=(); … … 3339 3241 $N400=0 if ($y==0); 3340 3242 3341 $dayofyear= &Date_DayOfYear($m,$d,$y);3243 $dayofyear=Date_DayOfYear($m,$d,$y); 3342 3244 $days= $Ny*365 + $N4 - $N100 + $N400 + $dayofyear; 3343 3245 … … 3348 3250 print "DEBUG: Date_DayOfYear\n" if ($Curr{"Debug"} =~ /trace/); 3349 3251 my($m,$d,$y)=@_; 3350 $y= &Date_FixYear($y) if (length($y)!=4);3252 $y=_Date_FixYear($y) if (length($y)!=4); 3351 3253 # DinM = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) 3352 3254 my(@days) = ( 0, 31, 59, 90,120,151,181,212,243,273,304,334,365); 3353 3255 my($ly)=0; 3354 $ly=1 if ($m>2 && &Date_LeapYear($y));3256 $ly=1 if ($m>2 && Date_LeapYear($y)); 3355 3257 return ($days[$m-1]+$d+$ly); 3356 3258 } … … 3359 3261 print "DEBUG: Date_DaysInYear\n" if ($Curr{"Debug"} =~ /trace/); 3360 3262 my($y)=@_; 3361 $y= &Date_FixYear($y) if (length($y)!=4);3362 return 366 if ( &Date_LeapYear($y));3263 $y=_Date_FixYear($y) if (length($y)!=4); 3264 return 366 if (Date_LeapYear($y)); 3363 3265 return 365; 3364 3266 } … … 3367 3269 print "DEBUG: Date_WeekOfYear\n" if ($Curr{"Debug"} =~ /trace/); 3368 3270 my($m,$d,$y,$f)=@_; 3369 &Date_Init() if (! $Curr{"InitDone"});3370 $y= &Date_FixYear($y) if (length($y)!=4);3271 Date_Init() if (! $Curr{"InitDone"}); 3272 $y=_Date_FixYear($y) if (length($y)!=4); 3371 3273 3372 3274 my($day,$dow,$doy)=(); 3373 $doy= &Date_DayOfYear($m,$d,$y);3275 $doy=Date_DayOfYear($m,$d,$y); 3374 3276 3375 3277 # The current DayOfYear and DayOfWeek … … 3379 3281 $day=4; 3380 3282 } 3381 $dow= &Date_DayOfWeek(1,$day,$y);3283 $dow=Date_DayOfWeek(1,$day,$y); 3382 3284 3383 3285 # Move back to the first day of week 1. … … 3392 3294 print "DEBUG: Date_LeapYear\n" if ($Curr{"Debug"} =~ /trace/); 3393 3295 my($y)=@_; 3394 $y= &Date_FixYear($y) if (length($y)!=4);3296 $y=_Date_FixYear($y) if (length($y)!=4); 3395 3297 return 0 unless $y % 4 == 0; 3396 3298 return 1 unless $y % 100 == 0; … … 3402 3304 print "DEBUG: Date_DaySuffix\n" if ($Curr{"Debug"} =~ /trace/); 3403 3305 my($d)=@_; 3404 &Date_Init() if (! $Curr{"InitDone"});3306 Date_Init() if (! $Curr{"InitDone"}); 3405 3307 return $Lang{$Cnf{"Language"}}{"DoML"}[$d-1]; 3406 3308 } … … 3409 3311 print "DEBUG: Date_ConvTZ\n" if ($Curr{"Debug"} =~ /trace/); 3410 3312 my($date,$from,$to,$level)=@_; 3411 if (not Date_Split($date)) {3313 if (not _Date_Split($date)) { 3412 3314 my $err = "date passed in ('$date') is not a Date::Manip object"; 3413 3315 if (! $level) { … … 3419 3321 } 3420 3322 3421 &Date_Init() if (! $Curr{"InitDone"});3323 Date_Init() if (! $Curr{"InitDone"}); 3422 3324 my($gmt)=(); 3423 3325 … … 3460 3362 my($s1,$h1,$m1,$s2,$h2,$m2,$d,$h,$m,$sign,$delta,$err,$yr,$mon,$sec)=(); 3461 3363 # We're going to try to do the calculation without calling DateCalc. 3462 ($yr,$mon,$d,$h,$m,$sec)= &Date_Split($date, 1);3364 ($yr,$mon,$d,$h,$m,$sec)=_Date_Split($date, 1); 3463 3365 3464 3366 # Convert $date from $from to GMT … … 3494 3396 $h -= $delta*24; 3495 3397 if (($d + $delta) > 28) { 3496 $date= &Date_Join($yr,$mon,$d,$h,$m,$sec);3497 return &DateCalc_DateDelta($date,"+0:0:0:$delta:0:0:0",\$err,0);3398 $date=_Date_Join($yr,$mon,$d,$h,$m,$sec); 3399 return _DateCalc_DateDelta($date,"+0:0:0:$delta:0:0:0",\$err,0); 3498 3400 } 3499 3401 $d+= $delta; … … 3502 3404 $h += $delta*24; 3503 3405 if (($d - $delta) < 1) { 3504 $date= &Date_Join($yr,$mon,$d,$h,$m,$sec);3505 return &DateCalc_DateDelta($date,"-0:0:0:$delta:0:0:0",\$err,0);3406 $date=_Date_Join($yr,$mon,$d,$h,$m,$sec); 3407 return _DateCalc_DateDelta($date,"-0:0:0:$delta:0:0:0",\$err,0); 3506 3408 } 3507 3409 $d-= $delta; 3508 3410 } 3509 return &Date_Join($yr,$mon,$d,$h,$m,$sec);3411 return _Date_Join($yr,$mon,$d,$h,$m,$sec); 3510 3412 } 3511 3413 … … 3513 3415 print "DEBUG: Date_TimeZone\n" if ($Curr{"Debug"} =~ /trace/); 3514 3416 my($null,$tz,@tz,$std,$dst,$time,$isdst,$tmp,$in)=(); 3515 &Date_Init() if (! $Curr{"InitDone"});3417 Date_Init() if (! $Curr{"InitDone"}); 3516 3418 3517 3419 # Get timezones from all of the relevant places … … 3560 3462 } 3561 3463 } 3562 push(@tz,$tz) ;3464 push(@tz,$tz) if (defined $tz); 3563 3465 } else { 3564 3466 # We need to satisfy taint checking, but also look in all the … … 3574 3476 $tz=(split(/\s+/,$tz))[4]; 3575 3477 } 3576 push(@tz,$tz) ;3478 push(@tz,$tz) if (defined $tz); 3577 3479 } 3578 3480 } … … 3607 3509 $in->close; 3608 3510 } 3511 3512 print STDERR "Found time zones: @tz\n"; 3609 3513 3610 3514 # Now parse each one to find the first valid one. … … 3645 3549 } 3646 3550 3647 confess "ERROR: Date::Manip unable to determine Time Zone from @tz.\n";3551 confess "ERROR: Date::Manip unable to determine Time Zone.\n"; 3648 3552 } 3649 3553 … … 3654 3558 print "DEBUG: Date_IsWorkDay\n" if ($Curr{"Debug"} =~ /trace/); 3655 3559 my($date,$time)=@_; 3656 &Date_Init() if (! $Curr{"InitDone"});3657 $date= &ParseDateString($date);3560 Date_Init() if (! $Curr{"InitDone"}); 3561 $date=ParseDateString($date); 3658 3562 return "" if (! $date); 3659 3563 my($d)=$date; 3660 $d= &Date_SetTime($date,$Cnf{"WorkDayBeg"}) if (! $time);3564 $d=Date_SetTime($date,$Cnf{"WorkDayBeg"}) if (! $time); 3661 3565 3662 3566 my($y,$mon,$day,$h,$m,$s,$dow)=(); 3663 ($y,$mon,$day,$h,$m,$s)= &Date_Split($d, 1);3664 $dow= &Date_DayOfWeek($mon,$day,$y);3567 ($y,$mon,$day,$h,$m,$s)=_Date_Split($d, 1); 3568 $dow=Date_DayOfWeek($mon,$day,$y); 3665 3569 3666 3570 return 0 if ($dow<$Cnf{"WorkWeekBeg"} or … … 3672 3576 # There will be recursion problems if we ever end up here twice. 3673 3577 $Holiday{"dates"}{$y}={}; 3674 &Date_UpdateHolidays($y)3675 } 3676 $d= &Date_SetTime($date,"00:00:00");3578 _Date_UpdateHolidays($y) 3579 } 3580 $d=Date_SetTime($date,"00:00:00"); 3677 3581 return 0 if (exists $Holiday{"dates"}{$y}{$d}); 3678 3582 1; … … 3690 3594 print "DEBUG: Date_NextWorkDay\n" if ($Curr{"Debug"} =~ /trace/); 3691 3595 my($date,$off,$time)=@_; 3692 &Date_Init() if (! $Curr{"InitDone"});3693 $date= &ParseDateString($date);3596 Date_Init() if (! $Curr{"InitDone"}); 3597 $date=ParseDateString($date); 3694 3598 my($err)=(); 3695 3599 3696 if (! &Date_IsWorkDay($date,$time)) {3600 if (! Date_IsWorkDay($date,$time)) { 3697 3601 if ($time) { 3698 3602 while (1) { 3699 $date= &Date_GetNext($date,undef,0,$Cnf{"WorkDayBeg"});3700 last if ( &Date_IsWorkDay($date,$time));3603 $date=Date_GetNext($date,undef,0,$Cnf{"WorkDayBeg"}); 3604 last if (Date_IsWorkDay($date,$time)); 3701 3605 } 3702 3606 } else { 3703 3607 while (1) { 3704 $date= &DateCalc_DateDelta($date,"+0:0:0:1:0:0:0",\$err,0);3705 last if ( &Date_IsWorkDay($date,$time));3608 $date=_DateCalc_DateDelta($date,"+0:0:0:1:0:0:0",\$err,0); 3609 last if (Date_IsWorkDay($date,$time)); 3706 3610 } 3707 3611 } … … 3710 3614 while ($off>0) { 3711 3615 while (1) { 3712 $date= &DateCalc_DateDelta($date,"+0:0:0:1:0:0:0",\$err,0);3713 last if ( &Date_IsWorkDay($date,$time));3616 $date=_DateCalc_DateDelta($date,"+0:0:0:1:0:0:0",\$err,0); 3617 last if (Date_IsWorkDay($date,$time)); 3714 3618 } 3715 3619 $off--; … … 3732 3636 print "DEBUG: Date_PrevWorkDay\n" if ($Curr{"Debug"} =~ /trace/); 3733 3637 my($date,$off,$time)=@_; 3734 &Date_Init() if (! $Curr{"InitDone"});3735 $date= &ParseDateString($date);3638 Date_Init() if (! $Curr{"InitDone"}); 3639 $date=ParseDateString($date); 3736 3640 my($err)=(); 3737 3641 3738 if (! &Date_IsWorkDay($date,$time)) {3642 if (! Date_IsWorkDay($date,$time)) { 3739 3643 if ($time) { 3740 3644 while (1) { 3741 $date= &Date_GetPrev($date,undef,0,$Cnf{"WorkDayEnd"});3742 last if ( &Date_IsWorkDay($date,$time));3645 $date=Date_GetPrev($date,undef,0,$Cnf{"WorkDayEnd"}); 3646 last if (Date_IsWorkDay($date,$time)); 3743 3647 } 3744 3648 while (1) { 3745 $date= &Date_GetNext($date,undef,0,$Cnf{"WorkDayBeg"});3746 last if ( &Date_IsWorkDay($date,$time));3649 $date=Date_GetNext($date,undef,0,$Cnf{"WorkDayBeg"}); 3650 last if (Date_IsWorkDay($date,$time)); 3747 3651 } 3748 3652 } else { 3749 3653 while (1) { 3750 $date= &DateCalc_DateDelta($date,"-0:0:0:1:0:0:0",\$err,0);3751 last if ( &Date_IsWorkDay($date,$time));3654 $date=_DateCalc_DateDelta($date,"-0:0:0:1:0:0:0",\$err,0); 3655 last if (Date_IsWorkDay($date,$time)); 3752 3656 } 3753 3657 } … … 3756 3660 while ($off>0) { 3757 3661 while (1) { 3758 $date= &DateCalc_DateDelta($date,"-0:0:0:1:0:0:0",\$err,0);3759 last if ( &Date_IsWorkDay($date,$time));3662 $date=_DateCalc_DateDelta($date,"-0:0:0:1:0:0:0",\$err,0); 3663 last if (Date_IsWorkDay($date,$time)); 3760 3664 } 3761 3665 $off--; … … 3770 3674 print "DEBUG: Date_NearestWorkDay\n" if ($Curr{"Debug"} =~ /trace/); 3771 3675 my($date,$tomorrow)=@_; 3772 &Date_Init() if (! $Curr{"InitDone"});3773 $date= &ParseDateString($date);3676 Date_Init() if (! $Curr{"InitDone"}); 3677 $date=ParseDateString($date); 3774 3678 my($a,$b,$dela,$delb,$err)=(); 3775 3679 $tomorrow=$Cnf{"TomorrowFirst"} if (! defined $tomorrow); 3776 3680 3777 return $date if ( &Date_IsWorkDay($date));3681 return $date if (Date_IsWorkDay($date)); 3778 3682 3779 3683 # Find the nearest one. … … 3788 3692 3789 3693 while (1) { 3790 $a= &DateCalc_DateDelta($a,$dela,\$err);3791 return $a if ( &Date_IsWorkDay($a));3792 $b= &DateCalc_DateDelta($b,$delb,\$err);3793 return $b if ( &Date_IsWorkDay($b));3794 } 3795 } 3796 3797 # &Date_NthDayOfYear($y,$n);3694 $a=_DateCalc_DateDelta($a,$dela,\$err); 3695 return $a if (Date_IsWorkDay($a)); 3696 $b=_DateCalc_DateDelta($b,$delb,\$err); 3697 return $b if (Date_IsWorkDay($b)); 3698 } 3699 } 3700 3701 # Date_NthDayOfYear($y,$n); 3798 3702 # Returns a list of (YYYY,MM,DD,HH,MM,SS) for the Nth day of the year. 3799 3703 sub Date_NthDayOfYear { … … 3804 3708 $n=1 if (! defined $n or $n eq ""); 3805 3709 $n+=0; # to turn 023 into 23 3806 $y= &Date_FixYear($y) if (length($y)<4);3807 my $leap= &Date_LeapYear($y);3710 $y=_Date_FixYear($y) if (length($y)<4); 3711 my $leap=Date_LeapYear($y); 3808 3712 return () if ($n<1); 3809 3713 return () if ($n >= ($leap ? 367 : 366)); … … 3856 3760 # $hash = { key1=>val1 key2=>val2 ... } 3857 3761 3858 sub Date_InitHash {3859 print "DEBUG: Date_InitHash\n" if ($Curr{"Debug"} =~ /trace/);3762 sub _Date_InitHash { 3763 print "DEBUG: _Date_InitHash\n" if ($Curr{"Debug"} =~ /trace/); 3860 3764 my($data,$regexp,$opts,$hash)=@_; 3861 3765 my(@data)=@$data; … … 3879 3783 if ($regexp) { 3880 3784 @list=keys(%$hash); 3881 @list=sort sortByLength(@list) if ($sort);3785 @list=sort _sortByLength(@list) if ($sort); 3882 3786 if ($escape) { 3883 3787 foreach $val (@list) { … … 3918 3822 # $hash 3919 3823 3920 sub Date_InitLists {3921 print "DEBUG: Date_InitLists\n" if ($Curr{"Debug"} =~ /trace/);3824 sub _Date_InitLists { 3825 print "DEBUG: _Date_InitLists\n" if ($Curr{"Debug"} =~ /trace/); 3922 3826 my($data,$regexp,$opts,$lists,$hash)=@_; 3923 3827 my(@data)=@$data; … … 3934 3838 # Set each of the lists 3935 3839 if (@lists) { 3936 confess "ERROR: Date_InitLists: lists must be 1 per data\n"3840 confess "ERROR: _Date_InitLists: lists must be 1 per data\n" 3937 3841 if ($#lists != $#data); 3938 3842 for ($i=0; $i<=$#data; $i++) { … … 3972 3876 if ($regexp) { 3973 3877 @list=keys(%hash); 3974 @list=sort sortByLength(@list) if ($sort);3878 @list=sort _sortByLength(@list) if ($sort); 3975 3879 if ($escape) { 3976 3880 foreach $ele (@list) { … … 4000 3904 # $regexp = '(string1|string2|...)' 4001 3905 4002 sub Date_InitStrings {4003 print "DEBUG: Date_InitStrings\n" if ($Curr{"Debug"} =~ /trace/);3906 sub _Date_InitStrings { 3907 print "DEBUG: _Date_InitStrings\n" if ($Curr{"Debug"} =~ /trace/); 4004 3908 my($data,$regexp,$opts)=@_; 4005 3909 my(@list)=@{ $data }; … … 4014 3918 # Create the regular expression 4015 3919 my($ele)=(); 4016 @list=sort sortByLength(@list) if ($sort);3920 @list=sort _sortByLength(@list) if ($sort); 4017 3921 if ($escape) { 4018 3922 foreach $ele (@list) { … … 4062 3966 # val1 : treat the list as the keys of a hash with values 1 .. N 4063 3967 4064 # &Date_InitLists([$lang{"month_name"},$lang{"month_abb"}],3968 # _Date_InitLists([$lang{"month_name"},$lang{"month_abb"}], 4065 3969 # [\$Month,"lc,sort,back"], 4066 3970 # [\@Month,\@Mon], … … 4101 4005 # val0 : treat the list as the keys of a hash with values 0 .. N-1 4102 4006 # val1 : treat the list as the keys of a hash with values 1 .. N 4103 sub Date_Regexp {4104 print "DEBUG: Date_Regexp\n" if ($Curr{"Debug"} =~ /trace/);4007 sub _Date_Regexp { 4008 print "DEBUG: _Date_Regexp\n" if ($Curr{"Debug"} =~ /trace/); 4105 4009 my($list,$options,$array)=@_; 4106 4010 my(@list,$ret,%hash,$i)=(); … … 4141 4045 $list = join("&&&",@$list); 4142 4046 } else { 4143 confess "ERROR: Date_Regexp.\n";4047 confess "ERROR: _Date_Regexp.\n"; 4144 4048 } 4145 4049 … … 4167 4071 } 4168 4072 } 4169 @list=sort sortByLength(@list) if ($sort);4073 @list=sort _sortByLength(@list) if ($sort); 4170 4074 4171 4075 $ret="($back" . join("|",@list) . ")"; … … 4187 4091 # the day), but if appropriate, signs will be in front of all elements. 4188 4092 # Also, as many of the signs will be equivalent as possible. 4189 sub Delta_Normalize {4190 print "DEBUG: Delta_Normalize\n" if ($Curr{"Debug"} =~ /trace/);4093 sub _Delta_Normalize { 4094 print "DEBUG: _Delta_Normalize\n" if ($Curr{"Debug"} =~ /trace/); 4191 4095 my($delta,$mode)=@_; 4192 4096 return "" if (! $delta); … … 4205 4109 # be a negative delta). 4206 4110 4207 my($y,$mon,$w,$d,$h,$m,$s)= &Delta_Split($delta);4111 my($y,$mon,$w,$d,$h,$m,$s)=_Delta_Split($delta); 4208 4112 4209 4113 # We need to make sure that the signs of all parts of a delta are the … … 4283 4187 # specifies the default sign. Blank elements are set to 0. If the 4284 4188 # third element is non-nil, exactly 7 elements must be included. 4285 sub Delta_Split {4286 print "DEBUG: Delta_Split\n" if ($Curr{"Debug"} =~ /trace/);4189 sub _Delta_Split { 4190 print "DEBUG: _Delta_Split\n" if ($Curr{"Debug"} =~ /trace/); 4287 4191 my($delta,$sign,$exact)=@_; 4288 4192 my(@delta)=split(/:/,$delta); … … 4301 4205 # Reads up to 3 arguments. $h may contain the time in any international 4302 4206 # format. Any empty elements are set to 0. 4303 sub Date_ParseTime {4304 print "DEBUG: Date_ParseTime\n" if ($Curr{"Debug"} =~ /trace/);4207 sub _Date_ParseTime { 4208 print "DEBUG: _Date_ParseTime\n" if ($Curr{"Debug"} =~ /trace/); 4305 4209 my($h,$m,$s)=@_; 4306 my($t)= &CheckTime("one");4210 my($t)=_CheckTime("one"); 4307 4211 4308 4212 if (defined $h and $h =~ /$t/) { … … 4320 4224 # Forms a date with the 6 elements passed in (all of which must be defined). 4321 4225 # No check as to validity is made. 4322 sub Date_Join {4323 print "DEBUG: Date_Join\n" if ($Curr{"Debug"} =~ /trace/);4226 sub _Date_Join { 4227 print "DEBUG: _Date_Join\n" if ($Curr{"Debug"} =~ /trace/); 4324 4228 foreach (0 .. $#_) { 4325 croak "undefined arg $_ to Date_Join()" if not defined $_[$_];4229 croak "undefined arg $_ to _Date_Join()" if not defined $_[$_]; 4326 4230 } 4327 4231 my($y,$m,$d,$h,$mn,$s)=@_; … … 4341 4245 4342 4246 } else { 4343 confess "ERROR: Invalid internal format in Date_Join.\n";4247 confess "ERROR: Invalid internal format in _Date_Join.\n"; 4344 4248 } 4345 4249 $m="0$m" if (length($m)==1); … … 4354 4258 # If "one" or "two" is passed in, a regexp with 1/2 or 2 digit hours is 4355 4259 # returned. 4356 sub CheckTime {4357 print "DEBUG: CheckTime\n" if ($Curr{"Debug"} =~ /trace/);4260 sub _CheckTime { 4261 print "DEBUG: _CheckTime\n" if ($Curr{"Debug"} =~ /trace/); 4358 4262 my($time)=@_; 4359 4263 my($h)='(?:0?[0-9]|1[0-9]|2[0-3])'; … … 4385 4289 # This checks a recurrence. If it is valid, it splits it and returns the 4386 4290 # elements. Otherwise, it returns an empty list. 4387 # ($recur0,$recur1,$flags,$dateb,$date0,$date1)= &Recur_Split($recur);4388 sub Recur_Split {4389 print "DEBUG: Recur_Split\n" if ($Curr{"Debug"} =~ /trace/);4291 # ($recur0,$recur1,$flags,$dateb,$date0,$date1)=_Recur_Split($recur); 4292 sub _Recur_Split { 4293 print "DEBUG: _Recur_Split\n" if ($Curr{"Debug"} =~ /trace/); 4390 4294 my($recur)=@_; 4391 4295 my(@ret,@tmp); … … 4414 4318 # still not valid, () is returned. 4415 4319 # 4416 sub Date_Split {4417 print "DEBUG: Date_Split\n" if ($Curr{"Debug"} =~ /trace/);4320 sub _Date_Split { 4321 print "DEBUG: _Date_Split\n" if ($Curr{"Debug"} =~ /trace/); 4418 4322 my($date, $definitely_valid)=@_; 4419 4323 $definitely_valid = 0 if not defined $definitely_valid; … … 4439 4343 4440 4344 } else { 4441 confess "ERROR: Invalid internal format in Date_Split.\n";4345 confess "ERROR: Invalid internal format in _Date_Split.\n"; 4442 4346 } 4443 4347 … … 4455 4359 ($y,$m,$d,$h,$mn,$s)=($1,$2,$3,$4,$5,$6); 4456 4360 my(@d_in_m)=(0,31,28,31,30,31,30,31,31,30,31,30,31); 4457 $d_in_m[2]=29 if ( &Date_LeapYear($y));4361 $d_in_m[2]=29 if (Date_LeapYear($y)); 4458 4362 if ($d>$d_in_m[$m]) { 4459 4363 my $msg = "invalid date $date: day $d of month $m, but only $d_in_m[$m] days in that month"; … … 4477 4381 # This returns the date easter occurs on for a given year as ($month,$day). 4478 4382 # This is from the Calendar FAQ. 4479 sub Date_Easter {4383 sub _Date_Easter { 4480 4384 my($y)=@_; 4481 $y= &Date_FixYear($y) if (length($y)==2);4385 $y=_Date_FixYear($y) if (length($y)==2); 4482 4386 4483 4387 my($c) = $y/100; … … 4497 4401 # the 1st argument (with the 2nd argument the null list) and the year/month 4498 4402 # of these will be used. 4499 sub Date_Recur_WoM {4403 sub _Date_Recur_WoM { 4500 4404 my($y,$m,$w,$d)=@_; 4501 4405 my(@y)=@$y; … … 4507 4411 if (@m) { 4508 4412 foreach $m (@m) { 4509 return () if (! &IsInt($m,1,12));4413 return () if (! _IsInt($m,1,12)); 4510 4414 } 4511 4415 … … 4523 4427 } else { 4524 4428 foreach $d0 (@y) { 4525 @tmp= &Date_Split($d0);4429 @tmp=_Date_Split($d0); 4526 4430 return () if (! @tmp); 4527 4431 push(@tmp2,$tmp[0]); … … 4533 4437 return () if (! @w); 4534 4438 foreach $w (@w) { 4535 return () if ($w==0 || ! &IsInt($w,-5,5));4439 return () if ($w==0 || ! _IsInt($w,-5,5)); 4536 4440 } 4537 4441 4538 4442 if (@d) { 4539 4443 foreach $d (@d) { 4540 return () if ($d==0 || ! &IsInt($d,-7,7));4444 return () if ($d==0 || ! _IsInt($d,-7,7)); 4541 4445 $d += 8 if ($d < 0); 4542 4446 } … … 4548 4452 4549 4453 # Find 1st day of this month and next month 4550 $date0= &Date_Join($y,$m,1,0,0,0);4551 $date1= &DateCalc_DateDelta($date0,"+0:1:0:0:0:0:0");4454 $date0=_Date_Join($y,$m,1,0,0,0); 4455 $date1=_DateCalc_DateDelta($date0,"+0:1:0:0:0:0:0"); 4552 4456 4553 4457 foreach $d (@d) { 4554 4458 # Find 1st occurence of DOW (in both months) 4555 $d0= &Date_GetNext($date0,$d,1);4556 $d1= &Date_GetNext($date1,$d,1);4459 $d0=Date_GetNext($date0,$d,1); 4460 $d1=Date_GetNext($date1,$d,1); 4557 4461 4558 4462 @tmp=(); 4559 while ( &Date_Cmp($d0,$d1)<0) {4463 while (Date_Cmp($d0,$d1)<0) { 4560 4464 push(@tmp,$d0); 4561 $d0= &DateCalc_DateDelta($d0,"+0:0:1:0:0:0:0");4465 $d0=_DateCalc_DateDelta($d0,"+0:0:1:0:0:0:0"); 4562 4466 } 4563 4467 … … 4585 4489 # list is the first date>=$date1 (because sometimes the set part will 4586 4490 # move the date back into the range). 4587 sub Date_Recur {4491 sub _Date_Recur { 4588 4492 my($date0,$date1,$dateb,$delta)=@_; 4589 4493 my(@ret,$d)=(); 4590 4494 4591 while ( &Date_Cmp($dateb,$date0)<0) {4592 $dateb= &DateCalc_DateDelta($dateb,$delta);4593 } 4594 while ( &Date_Cmp($dateb,$date1)>=0) {4595 $dateb= &DateCalc_DateDelta($dateb,"-$delta");4495 while (Date_Cmp($dateb,$date0)<0) { 4496 $dateb=_DateCalc_DateDelta($dateb,$delta); 4497 } 4498 while (Date_Cmp($dateb,$date1)>=0) { 4499 $dateb=_DateCalc_DateDelta($dateb,"-$delta"); 4596 4500 } 4597 4501 4598 4502 # Add the dates $date0..$dateb 4599 4503 $d=$dateb; 4600 while ( &Date_Cmp($d,$date0)>=0) {4504 while (Date_Cmp($d,$date0)>=0) { 4601 4505 unshift(@ret,$d); 4602 $d= &DateCalc_DateDelta($d,"-$delta");4506 $d=_DateCalc_DateDelta($d,"-$delta"); 4603 4507 } 4604 4508 # Add the first date earler than the range … … 4606 4510 4607 4511 # Add the dates $dateb..$date1 4608 $d= &DateCalc_DateDelta($dateb,$delta);4609 while ( &Date_Cmp($d,$date1)<0) {4512 $d=_DateCalc_DateDelta($dateb,$delta); 4513 while (Date_Cmp($d,$date1)<0) { 4610 4514 push(@ret,$d); 4611 $d= &DateCalc_DateDelta($d,$delta);4515 $d=_DateCalc_DateDelta($d,$delta); 4612 4516 } 4613 4517 # Add the first date later than the range … … 4621 4525 # $h,$m,$s can each be values or lists "1-2,4". If any are equal to "-1", 4622 4526 # they are not set (and none of the larger elements are set). 4623 sub Date_RecurSetTime {4527 sub _Date_RecurSetTime { 4624 4528 my($date0,$date1,$dates,$h,$m,$s)=@_; 4625 4529 my(@dates)=@$dates; … … 4630 4534 4631 4535 if ($h ne "-1") { 4632 @h= &ReturnList($h);4536 @h=_ReturnList($h); 4633 4537 return () if ! (@h); 4634 4538 @h=sort { $a<=>$b } (@h); … … 4637 4541 foreach $date (@dates) { 4638 4542 foreach $h (@h) { 4639 push(@tmp, &Date_SetDateField($date,"h",$h,1));4543 push(@tmp,Date_SetDateField($date,"h",$h,1)); 4640 4544 } 4641 4545 } … … 4644 4548 4645 4549 if ($m ne "-1") { 4646 @m= &ReturnList($m);4550 @m=_ReturnList($m); 4647 4551 return () if ! (@m); 4648 4552 @m=sort { $a<=>$b } (@m); … … 4651 4555 foreach $date (@dates) { 4652 4556 foreach $m (@m) { 4653 push(@tmp, &Date_SetDateField($date,"mn",$m,1));4557 push(@tmp,Date_SetDateField($date,"mn",$m,1)); 4654 4558 } 4655 4559 } … … 4658 4562 4659 4563 if ($s ne "-1") { 4660 @s= &ReturnList($s);4564 @s=_ReturnList($s); 4661 4565 return () if ! (@s); 4662 4566 @s=sort { $a<=>$b } (@s); … … 4665 4569 foreach $date (@dates) { 4666 4570 foreach $s (@s) { 4667 push(@tmp, &Date_SetDateField($date,"s",$s,1));4571 push(@tmp,Date_SetDateField($date,"s",$s,1)); 4668 4572 } 4669 4573 } … … 4673 4577 @tmp=(); 4674 4578 foreach $date (@dates) { 4675 push(@tmp,$date) if ( &Date_Cmp($date,$date0)>=0 &&4676 &Date_Cmp($date,$date1)<0 &&4677 &Date_Split($date));4579 push(@tmp,$date) if (Date_Cmp($date,$date0)>=0 && 4580 Date_Cmp($date,$date1)<0 && 4581 _Date_Split($date)); 4678 4582 } 4679 4583 … … 4681 4585 } 4682 4586 4683 sub DateCalc_DateDate {4684 print "DEBUG: DateCalc_DateDate\n" if ($Curr{"Debug"} =~ /trace/);4587 sub _DateCalc_DateDate { 4588 print "DEBUG: _DateCalc_DateDate\n" if ($Curr{"Debug"} =~ /trace/); 4685 4589 my($D1,$D2,$mode)=@_; 4686 4590 my(@d_in_m)=(0,31,28,31,30,31,30,31,31,30,31,30,31); … … 4689 4593 # Exact mode 4690 4594 if ($mode==0) { 4691 my($y1,$m1,$d1,$h1,$mn1,$s1)= &Date_Split($D1, 1);4692 my($y2,$m2,$d2,$h2,$mn2,$s2)= &Date_Split($D2, 1);4595 my($y1,$m1,$d1,$h1,$mn1,$s1)=_Date_Split($D1, 1); 4596 my($y2,$m2,$d2,$h2,$mn2,$s2)=_Date_Split($D2, 1); 4693 4597 my($i,@delta,$d,$delta,$y)=(); 4694 4598 … … 4702 4606 $d=0; 4703 4607 if ($y2>$y1) { 4704 $d= &Date_DaysInYear($y1) - &Date_DayOfYear($m1,$d1,$y1);4705 $d+= &Date_DayOfYear($m2,$d2,$y2);4608 $d=Date_DaysInYear($y1) - Date_DayOfYear($m1,$d1,$y1); 4609 $d+=Date_DayOfYear($m2,$d2,$y2); 4706 4610 for ($y=$y1+1; $y<$y2; $y++) { 4707 $d+= &Date_DaysInYear($y);4611 $d+= Date_DaysInYear($y); 4708 4612 } 4709 4613 } elsif ($y2<$y1) { 4710 $d= &Date_DaysInYear($y2) - &Date_DayOfYear($m2,$d2,$y2);4711 $d+= &Date_DayOfYear($m1,$d1,$y1);4614 $d=Date_DaysInYear($y2) - Date_DayOfYear($m2,$d2,$y2); 4615 $d+=Date_DayOfYear($m1,$d1,$y1); 4712 4616 for ($y=$y2+1; $y<$y1; $y++) { 4713 $d+= &Date_DaysInYear($y);4617 $d+= Date_DaysInYear($y); 4714 4618 } 4715 4619 $d *= -1; 4716 4620 } else { 4717 $d= &Date_DayOfYear($m2,$d2,$y2) - &Date_DayOfYear($m1,$d1,$y1);4621 $d=Date_DayOfYear($m2,$d2,$y2) - Date_DayOfYear($m1,$d1,$y1); 4718 4622 } 4719 4623 $delta[2]=0; … … 4725 4629 4726 4630 $delta=join(":",@delta); 4727 $delta= &Delta_Normalize($delta,0);4631 $delta=_Delta_Normalize($delta,0); 4728 4632 return $delta; 4729 4633 } … … 4734 4638 # make sure both are work days 4735 4639 if ($mode==2 || $mode==3) { 4736 $date1= &Date_NextWorkDay($date1,0,1);4737 $date2= &Date_NextWorkDay($date2,0,1);4640 $date1=Date_NextWorkDay($date1,0,1); 4641 $date2=Date_NextWorkDay($date2,0,1); 4738 4642 } 4739 4643 4740 4644 # make sure date1 comes before date2 4741 if ( &Date_Cmp($date1,$date2)>0) {4645 if (Date_Cmp($date1,$date2)>0) { 4742 4646 $sign="-"; 4743 4647 $tmp=$date1; … … 4747 4651 $sign="+"; 4748 4652 } 4749 if ( &Date_Cmp($date1,$date2)==0) {4653 if (Date_Cmp($date1,$date2)==0) { 4750 4654 return "+0:+0:+0:+0:+0:+0:+0" if ($Cnf{"DeltaSigns"}); 4751 4655 return "+0:0:0:0:0:0:0"; 4752 4656 } 4753 4657 4754 my($y1,$m1,$d1,$h1,$mn1,$s1)= &Date_Split($date1, 1);4755 my($y2,$m2,$d2,$h2,$mn2,$s2)= &Date_Split($date2, 1);4658 my($y1,$m1,$d1,$h1,$mn1,$s1)=_Date_Split($date1, 1); 4659 my($y2,$m2,$d2,$h2,$mn2,$s2)=_Date_Split($date2, 1); 4756 4660 my($dy,$dm,$dw,$dd,$dh,$dmn,$ds,$ddd)=(0,0,0,0,0,0,0,0); 4757 4661 … … 4762 4666 $dm=0; 4763 4667 if ($dy>0) { 4764 $tmp= &DateCalc_DateDelta($date1,"+$dy:0:0:0:0:0:0",\$err,0);4765 if ( &Date_Cmp($tmp,$date2)>0) {4668 $tmp=_DateCalc_DateDelta($date1,"+$dy:0:0:0:0:0:0",\$err,0); 4669 if (Date_Cmp($tmp,$date2)>0) { 4766 4670 $dy--; 4767 4671 $tmp=$date1; 4768 $tmp= &DateCalc_DateDelta($date1,"+$dy:0:0:0:0:0:0",\$err,0)4672 $tmp=_DateCalc_DateDelta($date1,"+$dy:0:0:0:0:0:0",\$err,0) 4769 4673 if ($dy>0); 4770 4674 $dm=12; … … 4776 4680 $dm+=$m2-$m1; 4777 4681 if ($dm>0) { 4778 $tmp= &DateCalc_DateDelta($date1,"+0:$dm:0:0:0:0:0",\$err,0);4779 if ( &Date_Cmp($tmp,$date2)>0) {4682 $tmp=_DateCalc_DateDelta($date1,"+0:$dm:0:0:0:0:0",\$err,0); 4683 if (Date_Cmp($tmp,$date2)>0) { 4780 4684 $dm--; 4781 4685 $tmp=$date1; 4782 $tmp= &DateCalc_DateDelta($date1,"+0:$dm:0:0:0:0:0",\$err,0)4686 $tmp=_DateCalc_DateDelta($date1,"+0:$dm:0:0:0:0:0",\$err,0) 4783 4687 if ($dm>0); 4784 4688 } … … 4789 4693 # Aug 3 (Monday) -> Sep 3 (Sunday) -> Sep 4 (Monday) = 1 month 4790 4694 if ($mode==2) { 4791 if (! &Date_IsWorkDay($date1,0)) {4792 $date1= &Date_NextWorkDay($date1,0,1);4695 if (! Date_IsWorkDay($date1,0)) { 4696 $date1=Date_NextWorkDay($date1,0,1); 4793 4697 } 4794 4698 } … … 4799 4703 $dd=0; 4800 4704 while (1) { 4801 $tmp= &Date_NextWorkDay($date1,1,1);4802 if ( &Date_Cmp($tmp,$date2)<=0) {4705 $tmp=Date_NextWorkDay($date1,1,1); 4706 if (Date_Cmp($tmp,$date2)<=0) { 4803 4707 $dd++; 4804 4708 $date1=$tmp; … … 4809 4713 4810 4714 } else { 4811 ($y1,$m1,$d1)=( &Date_Split($date1, 1) )[0..2];4715 ($y1,$m1,$d1)=( _Date_Split($date1, 1) )[0..2]; 4812 4716 $dd=0; 4813 4717 # If we're jumping across months, set $d1 to the first of the next month … … 4815 4719 # of this month) 4816 4720 if ($m1!=$m2) { 4817 $d_in_m[2]=29 if ( &Date_LeapYear($y1));4721 $d_in_m[2]=29 if (Date_LeapYear($y1)); 4818 4722 $dd=$d_in_m[$m1]-$d1+1; 4819 4723 $d1=1; 4820 $tmp= &DateCalc_DateDelta($date1,"+0:0:0:$dd:0:0:0",\$err,0);4821 if ( &Date_Cmp($tmp,$date2)>0) {4724 $tmp=_DateCalc_DateDelta($date1,"+0:0:0:$dd:0:0:0",\$err,0); 4725 if (Date_Cmp($tmp,$date2)>0) { 4822 4726 $dd--; 4823 4727 $d1--; 4824 $tmp= &DateCalc_DateDelta($date1,"+0:0:0:$dd:0:0:0",\$err,0);4728 $tmp=_DateCalc_DateDelta($date1,"+0:0:0:$dd:0:0:0",\$err,0); 4825 4729 } 4826 4730 $date1=$tmp; … … 4830 4734 if ($d1<$d2) { 4831 4735 $ddd=$d2-$d1; 4832 $tmp= &DateCalc_DateDelta($date1,"+0:0:0:$ddd:0:0:0",\$err,0);4833 if ( &Date_Cmp($tmp,$date2)>0) {4736 $tmp=_DateCalc_DateDelta($date1,"+0:0:0:$ddd:0:0:0",\$err,0); 4737 if (Date_Cmp($tmp,$date2)>0) { 4834 4738 $ddd--; 4835 $tmp= &DateCalc_DateDelta($date1,"+0:0:0:$ddd:0:0:0",\$err,0);4739 $tmp=_DateCalc_DateDelta($date1,"+0:0:0:$ddd:0:0:0",\$err,0); 4836 4740 } 4837 4741 $date1=$tmp; … … 4842 4746 # in business mode, make sure h1 comes before h2 (if not find delta between 4843 4747 # now and end of day and move to start of next business day) 4844 $d1=( &Date_Split($date1, 1) )[2];4748 $d1=( _Date_Split($date1, 1) )[2]; 4845 4749 $dh=$dmn=$ds=0; 4846 4750 if ($mode==2 || $mode==3 and $d1 != $d2) { 4847 $tmp= &Date_SetTime($date1,$Cnf{"WorkDayEnd"});4848 $tmp= &DateCalc_DateDelta($tmp,"+0:0:0:0:0:1:0")4751 $tmp=Date_SetTime($date1,$Cnf{"WorkDayEnd"}); 4752 $tmp=_DateCalc_DateDelta($tmp,"+0:0:0:0:0:1:0") 4849 4753 if ($Cnf{"WorkDay24Hr"}); 4850 $tmp= &DateCalc_DateDate($date1,$tmp,0);4851 ($tmp,$tmp,$tmp,$tmp,$dh,$dmn,$ds)= &Delta_Split($tmp);4852 $date1= &Date_NextWorkDay($date1,1,0);4853 $date1= &Date_SetTime($date1,$Cnf{"WorkDayBeg"});4854 $d1=( &Date_Split($date1, 1) )[2];4754 $tmp=_DateCalc_DateDate($date1,$tmp,0); 4755 ($tmp,$tmp,$tmp,$tmp,$dh,$dmn,$ds)=_Delta_Split($tmp); 4756 $date1=Date_NextWorkDay($date1,1,0); 4757 $date1=Date_SetTime($date1,$Cnf{"WorkDayBeg"}); 4758 $d1=( _Date_Split($date1, 1) )[2]; 4855 4759 confess "ERROR: DateCalc DateDate Business.\n" if ($d1 != $d2); 4856 4760 } 4857 4761 4858 4762 # Hours, minutes, seconds 4859 $tmp= &DateCalc_DateDate($date1,$date2,0);4860 @tmp= &Delta_Split($tmp);4763 $tmp=_DateCalc_DateDate($date1,$date2,0); 4764 @tmp=_Delta_Split($tmp); 4861 4765 $dh += $tmp[4]; 4862 4766 $dmn += $tmp[5]; … … 4864 4768 4865 4769 $tmp="$sign$dy:$dm:0:$dd:$dh:$dmn:$ds"; 4866 &Delta_Normalize($tmp,$mode);4867 } 4868 4869 sub DateCalc_DeltaDelta {4870 print "DEBUG: DateCalc_DeltaDelta\n" if ($Curr{"Debug"} =~ /trace/);4770 _Delta_Normalize($tmp,$mode); 4771 } 4772 4773 sub _DateCalc_DeltaDelta { 4774 print "DEBUG: _DateCalc_DeltaDelta\n" if ($Curr{"Debug"} =~ /trace/); 4871 4775 my($D1,$D2,$mode)=@_; 4872 4776 my(@delta1,@delta2,$i,$delta,@delta)=(); 4873 4777 $mode=0 if (! defined $mode); 4874 4778 4875 @delta1= &Delta_Split($D1);4876 @delta2= &Delta_Split($D2);4779 @delta1=_Delta_Split($D1); 4780 @delta2=_Delta_Split($D2); 4877 4781 for ($i=0; $i<7; $i++) { 4878 4782 $delta[$i]=$delta1[$i]+$delta2[$i]; … … 4881 4785 4882 4786 $delta=join(":",@delta); 4883 $delta= &Delta_Normalize($delta,$mode);4787 $delta=_Delta_Normalize($delta,$mode); 4884 4788 return $delta; 4885 4789 } 4886 4790 4887 sub DateCalc_DateDelta {4888 print "DEBUG: DateCalc_DateDelta\n" if ($Curr{"Debug"} =~ /trace/);4791 sub _DateCalc_DateDelta { 4792 print "DEBUG: _DateCalc_DateDelta\n" if ($Curr{"Debug"} =~ /trace/); 4889 4793 my($D1,$D2,$errref,$mode)=@_; 4890 4794 my($date)=(); … … 4907 4811 4908 4812 # Date, delta 4909 my($y,$m,$d,$h,$mn,$s)= &Date_Split($D1, 1);4910 my($dy,$dm,$dw,$dd,$dh,$dmn,$ds)= &Delta_Split($D2);4813 my($y,$m,$d,$h,$mn,$s)=_Date_Split($D1, 1); 4814 my($dy,$dm,$dw,$dd,$dh,$dmn,$ds)=_Delta_Split($D2); 4911 4815 4912 4816 # do the month/year part … … 4915 4819 $y = "0$y"; 4916 4820 } 4917 &ModuloAddition(-12,$dm,\$m,\$y); # -12 means 1-12 instead of 0-114918 $d_in_m[2]=29 if ( &Date_LeapYear($y));4821 _ModuloAddition(-12,$dm,\$m,\$y); # -12 means 1-12 instead of 0-11 4822 $d_in_m[2]=29 if (Date_LeapYear($y)); 4919 4823 4920 4824 # if we have gone past the last day of a month, move the date back to … … 4928 4832 $dd += $dw*7; 4929 4833 } else { 4930 $date= &DateCalc_DateDelta(&Date_Join($y,$m,$d,$h,$mn,$s),4834 $date=_DateCalc_DateDelta(_Date_Join($y,$m,$d,$h,$mn,$s), 4931 4835 "+0:0:$dw:0:0:0:0",0); 4932 ($y,$m,$d,$h,$mn,$s)= &Date_Split($date, 1);4836 ($y,$m,$d,$h,$mn,$s)=_Date_Split($date, 1); 4933 4837 } 4934 4838 … … 4937 4841 if ($mode==2 || $mode==3) { 4938 4842 $d=$d_in_m[$m] if ($d>$d_in_m[$m]); 4939 $date= &Date_NextWorkDay(&Date_Join($y,$m,$d,$h,$mn,$s),0,1);4940 ($y,$m,$d,$h,$mn,$s)= &Date_Split($date, 1);4843 $date=Date_NextWorkDay(_Date_Join($y,$m,$d,$h,$mn,$s),0,1); 4844 ($y,$m,$d,$h,$mn,$s)=_Date_Split($date, 1); 4941 4845 } 4942 4846 4943 4847 # seconds, minutes, hours 4944 &ModuloAddition(60,$ds,\$s,\$mn);4848 _ModuloAddition(60,$ds,\$s,\$mn); 4945 4849 if ($mode==2 || $mode==3) { 4946 4850 while (1) { 4947 &ModuloAddition(60,$dmn,\$mn,\$h);4851 _ModuloAddition(60,$dmn,\$mn,\$h); 4948 4852 $h+= $dh; 4949 4853 … … 4973 4877 4974 4878 } else { 4975 &ModuloAddition(60,$dmn,\$mn,\$h);4976 &ModuloAddition(24,$dh,\$h,\$d);4879 _ModuloAddition(60,$dmn,\$mn,\$h); 4880 _ModuloAddition(24,$dh,\$h,\$d); 4977 4881 } 4978 4882 … … 4987 4891 if ($mode==2 || $mode==3) { 4988 4892 if ($dd>=0) { 4989 $date= &Date_NextWorkDay(&Date_Join($y,$m,$d,$h,$mn,$s),$dd,1);4893 $date=Date_NextWorkDay(_Date_Join($y,$m,$d,$h,$mn,$s),$dd,1); 4990 4894 } else { 4991 $date= &Date_PrevWorkDay(&Date_Join($y,$m,$d,$h,$mn,$s),-$dd,1);4992 } 4993 ($y,$m,$d,$h,$mn,$s)= &Date_Split($date, 1);4895 $date=Date_PrevWorkDay(_Date_Join($y,$m,$d,$h,$mn,$s),-$dd,1); 4896 } 4897 ($y,$m,$d,$h,$mn,$s)=_Date_Split($date, 1); 4994 4898 4995 4899 } else { 4996 $d_in_m[2]=29 if ( &Date_LeapYear($y));4900 $d_in_m[2]=29 if (Date_LeapYear($y)); 4997 4901 $d=$d_in_m[$m] if ($d>$d_in_m[$m]); 4998 4902 $d += $dd; … … 5002 4906 $m=12; 5003 4907 $y--; 5004 if ( &Date_LeapYear($y)) {4908 if (Date_LeapYear($y)) { 5005 4909 $d_in_m[2]=29; 5006 4910 } else { … … 5016 4920 $m=1; 5017 4921 $y++; 5018 if ( &Date_LeapYear($y)) {4922 if (Date_LeapYear($y)) { 5019 4923 $d_in_m[2]=29; 5020 4924 } else { … … 5029 4933 return; 5030 4934 } 5031 &Date_Join($y,$m,$d,$h,$mn,$s);5032 } 5033 5034 sub Date_UpdateHolidays {5035 print "DEBUG: Date_UpdateHolidays\n" if ($Curr{"Debug"} =~ /trace/);4935 _Date_Join($y,$m,$d,$h,$mn,$s); 4936 } 4937 4938 sub _Date_UpdateHolidays { 4939 print "DEBUG: _Date_UpdateHolidays\n" if ($Curr{"Debug"} =~ /trace/); 5036 4940 my($year)=@_; 5037 4941 $Holiday{"year"}=$year; … … 5042 4946 5043 4947 foreach $key (keys %{ $Holiday{"desc"} }) { 5044 @tmp= &Recur_Split($key);4948 @tmp=_Recur_Split($key); 5045 4949 if (@tmp) { 5046 $tmp= &ParseDateString("${year}010100:00:00");5047 ($date)= &ParseRecur($key,$tmp,$tmp,($year+1)."-01-01");4950 $tmp=ParseDateString("${year}010100:00:00"); 4951 ($date)=ParseRecur($key,$tmp,$tmp,($year+1)."-01-01"); 5048 4952 next if (! $date); 5049 4953 … … 5051 4955 # Date +/- Delta 5052 4956 ($date,$delta)=($1,$2); 5053 $tmp= &ParseDateString("$date $year");4957 $tmp=ParseDateString("$date $year"); 5054 4958 if ($tmp) { 5055 4959 $date=$tmp; 5056 4960 } else { 5057 $date= &ParseDateString($date);4961 $date=ParseDateString($date); 5058 4962 next if ($date !~ /^$year/); 5059 4963 } 5060 $date= &DateCalc($date,$delta,\$err,0);4964 $date=DateCalc($date,$delta,\$err,0); 5061 4965 5062 4966 } else { 5063 4967 # Date 5064 4968 $date=$key; 5065 $tmp= &ParseDateString("$date $year");4969 $tmp=ParseDateString("$date $year"); 5066 4970 if ($tmp) { 5067 4971 $date=$tmp; 5068 4972 } else { 5069 $date= &ParseDateString($date);4973 $date=ParseDateString($date); 5070 4974 next if ($date !~ /^$year/); 5071 4975 } … … 5076 4980 5077 4981 # This sets a Date::Manip config variable. 5078 sub Date_SetConfigVariable {5079 print "DEBUG: Date_SetConfigVariable\n" if ($Curr{"Debug"} =~ /trace/);4982 sub _Date_SetConfigVariable { 4983 print "DEBUG: _Date_SetConfigVariable\n" if ($Curr{"Debug"} =~ /trace/); 5080 4984 my($var,$val)=@_; 5081 4985 … … 5084 4988 $Cnf{"PersonalCnf"}=$val, return if ($var =~ /^PersonalCnf$/i); 5085 4989 $Cnf{"PersonalCnfPath"}=$val, return if ($var =~ /^PersonalCnfPath$/i); 5086 &EraseHolidays(), return if ($var =~ /^EraseHolidays$/i);4990 EraseHolidays(), return if ($var =~ /^EraseHolidays$/i); 5087 4991 $Cnf{"IgnoreGlobalCnf"}=1, return if ($var =~ /^IgnoreGlobalCnf$/i); 5088 4992 $Cnf{"GlobalCnf"}=$val, return if ($var =~ /^GlobalCnf$/i); … … 5133 5037 # 5134 5038 # This takes either one date or two dates as arguments. 5135 sub Events_Calc {5136 print "DEBUG: Events_Calc\n" if ($Curr{"Debug"} =~ /trace/);5039 sub _Events_Calc { 5040 print "DEBUG: _Events_Calc\n" if ($Curr{"Debug"} =~ /trace/); 5137 5041 5138 5042 my($date0,$date1)=@_; 5139 5043 5140 5044 my($tmp); 5141 $date0= &ParseDateString($date0);5045 $date0=ParseDateString($date0); 5142 5046 return undef if (! $date0); 5143 5047 if ($date1) { 5144 $date1= &ParseDateString($date1);5145 if ( &Date_Cmp($date0,$date1)>0) {5048 $date1=ParseDateString($date1); 5049 if (Date_Cmp($date0,$date1)>0) { 5146 5050 $tmp=$date1; 5147 5051 $date1=$date0; … … 5149 5053 } 5150 5054 } else { 5151 $date1= &DateCalc_DateDelta($date0,"+0:0:0:0:0:0:1");5055 $date1=_DateCalc_DateDelta($date0,"+0:0:0:0:0:0:1"); 5152 5056 } 5153 5057 … … 5160 5064 DATE: while (@tmp) { 5161 5065 ($d0,$d1,$del,$name)=splice(@tmp,0,4); 5162 $d0= &ParseDateString($d0);5163 $d1= &ParseDateString($d1) if ($d1);5164 $del= &ParseDateDelta($del) if ($del);5066 $d0=ParseDateString($d0); 5067 $d1=ParseDateString($d1) if ($d1); 5068 $del=ParseDateDelta($del) if ($del); 5165 5069 if ($d1) { 5166 5070 if ($del) { 5167 $d1= &DateCalc_DateDelta($d1,$del);5071 $d1=_DateCalc_DateDelta($d1,$del); 5168 5072 } 5169 5073 } else { 5170 $d1= &DateCalc_DateDelta($d0,$del);5171 } 5172 if ( &Date_Cmp($d0,$d1)>0) {5074 $d1=_DateCalc_DateDelta($d0,$del); 5075 } 5076 if (Date_Cmp($d0,$d1)>0) { 5173 5077 $tmp=$d1; 5174 5078 $d1=$d0; … … 5177 5081 # [ date0,date1 ) 5178 5082 # [ d0,d1 ) OR [ d0,d1 ) 5179 next DATE if ( &Date_Cmp($d1,$date0)<=0 ||5180 &Date_Cmp($d0,$date1)>=0);5083 next DATE if (Date_Cmp($d1,$date0)<=0 || 5084 Date_Cmp($d0,$date1)>=0); 5181 5085 # [ date0,date1 ) 5182 5086 # [ d0,d1 ) 5183 5087 # [ d0, d1 ) 5184 if ( &Date_Cmp($d0,$date0)<=0) {5088 if (Date_Cmp($d0,$date0)<=0) { 5185 5089 push @{ $ret{$date0} },$name; 5186 push @{ $ret{$d1} },"!$name" if ( &Date_Cmp($d1,$date1)<0);5090 push @{ $ret{$d1} },"!$name" if (Date_Cmp($d1,$date1)<0); 5187 5091 next DATE; 5188 5092 } 5189 5093 # [ date0,date1 ) 5190 5094 # [ d0,d1 ) 5191 if ( &Date_Cmp($d1,$date1)>=0) {5095 if (Date_Cmp($d1,$date1)>=0) { 5192 5096 push @{ $ret{$d0} },$name; 5193 5097 next DATE; … … 5212 5116 # Sort them AND take into account the "!$name" entries. 5213 5117 my(%tmp,$date,@tmp2,@ret); 5214 @d=sort { &Date_Cmp($a,$b) } keys %ret;5118 @d=sort { Date_Cmp($a,$b) } keys %ret; 5215 5119 foreach $date (@d) { 5216 5120 @tmp=@{ $ret{$date} }; … … 5237 5141 5238 5142 # This parses the raw events list 5239 sub Events_ParseRaw {5240 print "DEBUG: Events_ParseRaw\n" if ($Curr{"Debug"} =~ /trace/);5143 sub _Events_ParseRaw { 5144 print "DEBUG: _Events_ParseRaw\n" if ($Curr{"Debug"} =~ /trace/); 5241 5145 5242 5146 # Only need to be parsed once … … 5255 5159 if ($#event == 0) { 5256 5160 5257 if ($date0= &ParseDateString($event[0])) {5161 if ($date0=ParseDateString($event[0])) { 5258 5162 # 5259 5163 # date = event 5260 5164 # 5261 $tmp= &ParseDateString("$event[0] 00:00:00");5165 $tmp=ParseDateString("$event[0] 00:00:00"); 5262 5166 if ($tmp && $tmp eq $date0) { 5263 5167 $delta="+0:0:0:1:0:0:0"; … … 5267 5171 push @{ $Events{"dates"} },($date0,0,$delta,$name); 5268 5172 5269 } elsif ($recur= &ParseRecur($event[0])) {5173 } elsif ($recur=ParseRecur($event[0])) { 5270 5174 # 5271 5175 # recur = event 5272 5176 # 5273 ($recur0,$recur1)= &Recur_Split($recur);5177 ($recur0,$recur1)=_Recur_Split($recur); 5274 5178 if ($recur0) { 5275 5179 if ($recur1) { … … 5297 5201 } elsif ($#event == 1) { 5298 5202 5299 if ($date0= &ParseDateString($event[0])) {5300 5301 if ($date1= &ParseDateString($event[1])) {5203 if ($date0=ParseDateString($event[0])) { 5204 5205 if ($date1=ParseDateString($event[1])) { 5302 5206 # 5303 5207 # date ; date = event 5304 5208 # 5305 $tmp= &ParseDateString("$event[1] 00:00:00");5209 $tmp=ParseDateString("$event[1] 00:00:00"); 5306 5210 if ($tmp && $tmp eq $date1) { 5307 $date1= &DateCalc_DateDelta($date1,"+0:0:0:1:0:0:0");5211 $date1=_DateCalc_DateDelta($date1,"+0:0:0:1:0:0:0"); 5308 5212 } 5309 5213 push @{ $Events{"dates"} },($date0,$date1,0,$name); 5310 5214 5311 } elsif ($delta= &ParseDateDelta($event[1])) {5215 } elsif ($delta=ParseDateDelta($event[1])) { 5312 5216 # 5313 5217 # date ; delta = event … … 5321 5225 } 5322 5226 5323 } elsif ($recur= &ParseRecur($event[0])) {5324 5325 if ($delta= &ParseDateDelta($event[1])) {5227 } elsif ($recur=ParseRecur($event[0])) { 5228 5229 if ($delta=ParseDateDelta($event[1])) { 5326 5230 # 5327 5231 # recur ; delta = event … … 5352 5256 5353 5257 # This reads an init file. 5354 sub Date_InitFile {5355 print "DEBUG: Date_InitFile\n" if ($Curr{"Debug"} =~ /trace/);5258 sub _Date_InitFile { 5259 print "DEBUG: _Date_InitFile\n" if ($Curr{"Debug"} =~ /trace/); 5356 5260 my($file)=@_; 5357 5261 my($in)=new IO::File; … … 5369 5273 if (/^\*holiday/i) { 5370 5274 $section="holiday"; 5371 &EraseHolidays() if ($section =~ /holiday/i && $Cnf{"EraseHolidays"});5275 EraseHolidays() if ($section =~ /holiday/i && $Cnf{"EraseHolidays"}); 5372 5276 next; 5373 5277 } elsif (/^\*events/i) { … … 5380 5284 if (! /(.*\S)\s*=\s*(.*)$/); 5381 5285 ($var,$val)=($1,$2); 5382 &Date_SetConfigVariable($var,$val);5286 _Date_SetConfigVariable($var,$val); 5383 5287 5384 5288 } elsif ($section =~ /holiday/i) { … … 5404 5308 } 5405 5309 5406 # $flag= &Date_TimeCheck(\$h,\$mn,\$s,\$ampm);5310 # $flag=_Date_TimeCheck(\$h,\$mn,\$s,\$ampm); 5407 5311 # Returns 1 if any of the fields are bad. All fields are optional, and 5408 5312 # all possible checks are done on the data. If a field is not passed in, 5409 5313 # it is set to default values. If data is missing, appropriate defaults 5410 5314 # are supplied. 5411 sub Date_TimeCheck {5412 print "DEBUG: Date_TimeCheck\n" if ($Curr{"Debug"} =~ /trace/);5315 sub _Date_TimeCheck { 5316 print "DEBUG: _Date_TimeCheck\n" if ($Curr{"Debug"} =~ /trace/); 5413 5317 my($h,$mn,$s,$ampm)=@_; 5414 5318 my($tmp1,$tmp2,$tmp3)=(); … … 5439 5343 $$h="00" if ($$h eq ""); 5440 5344 $$h="0$$h" if (length($$h)==1); 5441 return 1 if (! &IsInt($$h,0,23));5345 return 1 if (! _IsInt($$h,0,23)); 5442 5346 $tmp2="AM" if ($$h<12); 5443 5347 $tmp2="PM" if ($$h>=12); … … 5449 5353 $$mn="00" if ($$mn eq ""); 5450 5354 $$mn="0$$mn" if (length($$mn)==1); 5451 return 1 if (! &IsInt($$mn,0,59));5355 return 1 if (! _IsInt($$mn,0,59)); 5452 5356 5453 5357 # Check seconds 5454 5358 $$s="00" if ($$s eq ""); 5455 5359 $$s="0$$s" if (length($$s)==1); 5456 return 1 if (! &IsInt($$s,0,59));5360 return 1 if (! _IsInt($$s,0,59)); 5457 5361 5458 5362 return 0; 5459 5363 } 5460 5364 5461 # $flag= &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk);5365 # $flag=_Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk); 5462 5366 # Returns 1 if any of the fields are bad. All fields are optional, and 5463 5367 # all possible checks are done on the data. If a field is not passed in, … … 5467 5371 # If the flag UpdateHolidays is set, the year is set to 5468 5372 # CurrHolidayYear. 5469 sub Date_DateCheck {5470 print "DEBUG: Date_DateCheck\n" if ($Curr{"Debug"} =~ /trace/);5373 sub _Date_DateCheck { 5374 print "DEBUG: _Date_DateCheck\n" if ($Curr{"Debug"} =~ /trace/); 5471 5375 my($y,$m,$d,$h,$mn,$s,$ampm,$wk)=@_; 5472 5376 my($tmp1,$tmp2,$tmp3)=(); … … 5485 5389 # Check year. 5486 5390 $$y=$curr_y if ($$y eq ""); 5487 $$y= &Date_FixYear($$y) if (length($$y)<4);5488 return 1 if (! &IsInt($$y,0,9999));5489 $d_in_m[2]=29 if ( &Date_LeapYear($$y));5391 $$y=_Date_FixYear($$y) if (length($$y)<4); 5392 return 1 if (! _IsInt($$y,0,9999)); 5393 $d_in_m[2]=29 if (Date_LeapYear($$y)); 5490 5394 5491 5395 # Check month … … 5494 5398 if (exists $Lang{$Cnf{"Language"}}{"MonthH"}{lc($$m)}); 5495 5399 $$m="0$$m" if (length($$m)==1); 5496 return 1 if (! &IsInt($$m,1,12));5400 return 1 if (! _IsInt($$m,1,12)); 5497 5401 5498 5402 # Check day 5499 5403 $$d="01" if ($$d eq ""); 5500 5404 $$d="0$$d" if (length($$d)==1); 5501 return 1 if (! &IsInt($$d,1,$d_in_m[$$m]));5405 return 1 if (! _IsInt($$d,1,$d_in_m[$$m])); 5502 5406 if ($$wk) { 5503 $tmp1= &Date_DayOfWeek($$m,$$d,$$y);5407 $tmp1=Date_DayOfWeek($$m,$$d,$$y); 5504 5408 $tmp2=$Lang{$Cnf{"Language"}}{"WeekH"}{lc($$wk)} 5505 5409 if (exists $Lang{$Cnf{"Language"}}{"WeekH"}{lc($$wk)}); … … 5507 5411 } 5508 5412 5509 return &Date_TimeCheck($h,$mn,$s,$ampm);5413 return _Date_TimeCheck($h,$mn,$s,$ampm); 5510 5414 } 5511 5415 5512 5416 # Takes a year in 2 digit form and returns it in 4 digit form 5513 sub Date_FixYear {5514 print "DEBUG: Date_FixYear\n" if ($Curr{"Debug"} =~ /trace/);5417 sub _Date_FixYear { 5418 print "DEBUG: _Date_FixYear\n" if ($Curr{"Debug"} =~ /trace/); 5515 5419 my($y)=@_; 5516 5420 my($curr_y)=$Curr{"Y"}; … … 5521 5425 5522 5426 if (lc($Cnf{"YYtoYYYY"}) eq "c") { 5523 $y1=substr ing($y,0,2);5427 $y1=substr($y,0,2); 5524 5428 $y="$y1$y"; 5525 5429 … … 5547 5451 } 5548 5452 5549 # &Date_NthWeekOfYear($y,$n);5453 # _Date_NthWeekOfYear($y,$n); 5550 5454 # Returns a list of (YYYY,MM,DD) for the 1st day of the Nth week of the 5551 5455 # year. 5552 # &Date_NthWeekOfYear($y,$n,$dow,$flag);5456 # _Date_NthWeekOfYear($y,$n,$dow,$flag); 5553 5457 # Returns a list of (YYYY,MM,DD) for the Nth DoW of the year. If flag 5554 5458 # is nil, the first DoW of the year may actually be in the previous … … 5556 5460 # If flag is non-nil, the 1st DoW of the year refers to the 1st one 5557 5461 # actually in the year 5558 sub Date_NthWeekOfYear {5559 print "DEBUG: Date_NthWeekOfYear\n" if ($Curr{"Debug"} =~ /trace/);5462 sub _Date_NthWeekOfYear { 5463 print "DEBUG: _Date_NthWeekOfYear\n" if ($Curr{"Debug"} =~ /trace/); 5560 5464 my($y,$n,$dow,$flag)=@_; 5561 5465 my($m,$d,$err,$tmp,$date,%dow)=(); … … 5574 5478 } 5575 5479 5576 $y= &Date_FixYear($y) if (length($y)<4);5480 $y=_Date_FixYear($y) if (length($y)<4); 5577 5481 if ($Cnf{"Jan1Week1"}) { 5578 $date= &Date_Join($y,1,1,0,0,0);5482 $date=_Date_Join($y,1,1,0,0,0); 5579 5483 } else { 5580 $date= &Date_Join($y,1,4,0,0,0);5581 } 5582 $date= &Date_GetPrev($date,$Cnf{"FirstDay"},1);5583 $date= &Date_GetNext($date,$dow,1) if ($dow ne "");5484 $date=_Date_Join($y,1,4,0,0,0); 5485 } 5486 $date=Date_GetPrev($date,$Cnf{"FirstDay"},1); 5487 $date=Date_GetNext($date,$dow,1) if ($dow ne ""); 5584 5488 5585 5489 if ($flag) { 5586 ($tmp)= &Date_Split($date, 1);5490 ($tmp)=_Date_Split($date, 1); 5587 5491 $n++ if ($tmp != $y); 5588 5492 } 5589 5493 5590 5494 if ($n>1) { 5591 $date= &DateCalc_DateDelta($date,"+0:0:". ($n-1) . ":0:0:0:0",\$err,0);5495 $date=_DateCalc_DateDelta($date,"+0:0:". ($n-1) . ":0:0:0:0",\$err,0); 5592 5496 } elsif ($n==0) { 5593 $date= &DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0);5594 } 5595 ($y,$m,$d)= &Date_Split($date, 1);5497 $date=_DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0); 5498 } 5499 ($y,$m,$d)=_Date_Split($date, 1); 5596 5500 ($y,$m,$d); 5597 5501 } … … 5603 5507 # 8-bit international characters can be gotten by "\xXX". I don't know 5604 5508 # how to get 16-bit characters. I've got to read up on perllocale. 5605 sub Char_8Bit {5509 sub _Char_8Bit { 5606 5510 my($hash)=@_; 5607 5511 … … 5830 5734 } 5831 5735 5832 # $hashref = &Date_Init_LANGUAGE;5736 # $hashref = _Date_Init_LANGUAGE; 5833 5737 # This returns a hash containing all of the initialization for a 5834 5738 # specific language. The hash elements are: … … 5912 5816 # every language. 5913 5817 5914 sub Date_Init_English {5915 print "DEBUG: Date_Init_English\n" if ($Curr{"Debug"} =~ /trace/);5818 sub _Date_Init_English { 5819 print "DEBUG: _Date_Init_English\n" if ($Curr{"Debug"} =~ /trace/); 5916 5820 my($d)=@_; 5917 5821 … … 5964 5868 $$d{"business"}=["business"]; 5965 5869 5966 $$d{"offset"} =["yesterday","-0:0:0:1:0:0:0","tomorrow","+0:0:0:1:0:0:0","overmorrow","+0:0:0:2:0:0:0" ];5870 $$d{"offset"} =["yesterday","-0:0:0:1:0:0:0","tomorrow","+0:0:0:1:0:0:0","overmorrow","+0:0:0:2:0:0:0","ereyesterday","-0:0:0:2:0:0:0"]; 5967 5871 $$d{"times"} =["noon","12:00:00","midnight","00:00:00"]; 5968 5872 … … 5984 5888 } 5985 5889 5986 sub Date_Init_Italian {5987 print "DEBUG: Date_Init_Italian\n" if ($Curr{"Debug"} =~ /trace/);5890 sub _Date_Init_Italian { 5891 print "DEBUG: _Date_Init_Italian\n" if ($Curr{"Debug"} =~ /trace/); 5988 5892 my($d)=@_; 5989 5893 my(%h)=(); 5990 &Char_8Bit(\%h);5894 _Char_8Bit(\%h); 5991 5895 my($i)=$h{"i`"}; 5992 5896 … … 6055 5959 } 6056 5960 6057 sub Date_Init_French {6058 print "DEBUG: Date_Init_French\n" if ($Curr{"Debug"} =~ /trace/);5961 sub _Date_Init_French { 5962 print "DEBUG: _Date_Init_French\n" if ($Curr{"Debug"} =~ /trace/); 6059 5963 my($d)=@_; 6060 5964 my(%h)=(); 6061 &Char_8Bit(\%h);5965 _Char_8Bit(\%h); 6062 5966 my($e)=$h{"e'"}; 6063 5967 my($u)=$h{"u^"}; … … 6132 6036 } 6133 6037 6134 sub Date_Init_Romanian {6135 print "DEBUG: Date_Init_Romanian\n" if ($Curr{"Debug"} =~ /trace/);6038 sub _Date_Init_Romanian { 6039 print "DEBUG: _Date_Init_Romanian\n" if ($Curr{"Debug"} =~ /trace/); 6136 6040 my($d)=@_; 6137 6041 my(%h)=(); 6138 &Char_8Bit(\%h);6042 _Char_8Bit(\%h); 6139 6043 my($p)=$h{"p"}; 6140 6044 my($i)=$h{"i^"}; … … 6249 6153 } 6250 6154 6251 sub Date_Init_Swedish {6252 print "DEBUG: Date_Init_Swedish\n" if ($Curr{"Debug"} =~ /trace/);6155 sub _Date_Init_Swedish { 6156 print "DEBUG: _Date_Init_Swedish\n" if ($Curr{"Debug"} =~ /trace/); 6253 6157 my($d)=@_; 6254 6158 my(%h)=(); 6255 &Char_8Bit(\%h);6159 _Char_8Bit(\%h); 6256 6160 my($ao)=$h{"ao"}; 6257 6161 my($o) =$h{"o:"}; … … 6333 6237 } 6334 6238 6335 sub Date_Init_German {6336 print "DEBUG: Date_Init_German\n" if ($Curr{"Debug"} =~ /trace/);6239 sub _Date_Init_German { 6240 print "DEBUG: _Date_Init_German\n" if ($Curr{"Debug"} =~ /trace/); 6337 6241 my($d)=@_; 6338 6242 my(%h)=(); 6339 &Char_8Bit(\%h);6243 _Char_8Bit(\%h); 6340 6244 my($a)=$h{"a:"}; 6341 6245 my($u)=$h{"u:"}; … … 6422 6326 } 6423 6327 6424 sub Date_Init_Dutch {6425 print "DEBUG: Date_Init_Dutch\n" if ($Curr{"Debug"} =~ /trace/);6328 sub _Date_Init_Dutch { 6329 print "DEBUG: _Date_Init_Dutch\n" if ($Curr{"Debug"} =~ /trace/); 6426 6330 my($d)=@_; 6427 6331 my(%h)=(); 6428 &Char_8Bit(\%h);6332 _Char_8Bit(\%h); 6429 6333 6430 6334 $$d{"month_name"}= … … 6514 6418 } 6515 6419 6516 sub Date_Init_Polish {6517 print "DEBUG: Date_Init_Polish\n" if ($Curr{"Debug"} =~ /trace/);6420 sub _Date_Init_Polish { 6421 print "DEBUG: _Date_Init_Polish\n" if ($Curr{"Debug"} =~ /trace/); 6518 6422 my($d)=@_; 6519 6423 … … 6613 6517 } 6614 6518 6615 sub Date_Init_Spanish {6616 print "DEBUG: Date_Init_Spanish\n" if ($Curr{"Debug"} =~ /trace/);6519 sub _Date_Init_Spanish { 6520 print "DEBUG: _Date_Init_Spanish\n" if ($Curr{"Debug"} =~ /trace/); 6617 6521 my($d)=@_; 6618 6522 my(%h)=(); 6619 &Char_8Bit(\%h);6523 _Char_8Bit(\%h); 6620 6524 6621 6525 $$d{"month_name"}= … … 6696 6600 } 6697 6601 6698 sub Date_Init_Portuguese {6699 print "DEBUG: Date_Init_Portuguese\n" if ($Curr{"Debug"} =~ /trace/);6602 sub _Date_Init_Portuguese { 6603 print "DEBUG: _Date_Init_Portuguese\n" if ($Curr{"Debug"} =~ /trace/); 6700 6604 my($d)=@_; 6701 6605 my(%h)=(); 6702 &Char_8Bit(\%h);6606 _Char_8Bit(\%h); 6703 6607 my($o) = $h{"-o"}; 6704 6608 my($c) = $h{",c"}; … … 6792 6696 } 6793 6697 6794 sub Date_Init_Russian {6795 print "DEBUG: Date_Init_Russian\n" if ($Curr{"Debug"} =~ /trace/);6698 sub _Date_Init_Russian { 6699 print "DEBUG: _Date_Init_Russian\n" if ($Curr{"Debug"} =~ /trace/); 6796 6700 my($d)=@_; 6797 6701 my(%h)=(); 6798 &Char_8Bit(\%h);6702 _Char_8Bit(\%h); 6799 6703 my($a) =$h{"a:"}; 6800 6704 … … 6980 6884 } 6981 6885 6982 sub Date_Init_Turkish {6983 print "DEBUG: Date_Init_Turkish\n" if ($Curr{"Debug"} =~ /trace/);6886 sub _Date_Init_Turkish { 6887 print "DEBUG: _Date_Init_Turkish\n" if ($Curr{"Debug"} =~ /trace/); 6984 6888 my($d)=@_; 6985 6889 … … 7091 6995 } 7092 6996 7093 sub Date_Init_Danish {7094 print "DEBUG: Date_Init_Danish\n" if ($Curr{"Debug"} =~ /trace/);6997 sub _Date_Init_Danish { 6998 print "DEBUG: _Date_Init_Danish\n" if ($Curr{"Debug"} =~ /trace/); 7095 6999 my($d)=@_; 7096 7000 … … 7170 7074 } 7171 7075 7172 sub Date_Init_Catalan {7173 print "DEBUG: Date_Init_Catalan\n" if ($Curr{"Debug"} =~ /trace/);7076 sub _Date_Init_Catalan { 7077 print "DEBUG: _Date_Init_Catalan\n" if ($Curr{"Debug"} =~ /trace/); 7174 7078 my($d)=@_; 7175 7079 … … 7266 7170 no integer; 7267 7171 7268 # &ModuloAddition($N,$add,\$val,\$rem);7172 # _ModuloAddition($N,$add,\$val,\$rem); 7269 7173 # This calculates $val=$val+$add and forces $val to be in a certain range. 7270 7174 # This is useful for adding numbers for which only a certain range is … … 7275 7179 # Example: 7276 7180 # To add 2 hours together (with the excess returned in days) use: 7277 # &ModuloAddition(60,$s1,\$s,\$day);7278 sub ModuloAddition {7181 # _ModuloAddition(60,$s1,\$s,\$day); 7182 sub _ModuloAddition { 7279 7183 my($N,$add,$val,$rem)=@_; 7280 7184 return if ($N==0); … … 7303 7207 } 7304 7208 7305 # $Flag= &IsInt($String [,$low, $high]);7209 # $Flag=_IsInt($String [,$low, $high]); 7306 7210 # Returns 1 if $String is a valid integer, 0 otherwise. If $low is 7307 7211 # entered, $String must be >= $low. If $high is entered, $String must 7308 7212 # be <= $high. It is valid to check only one of the bounds. 7309 sub IsInt {7213 sub _IsInt { 7310 7214 my($N,$low,$high)=@_; 7311 7215 return 0 if (! defined $N or … … 7316 7220 } 7317 7221 7318 # $Pos=&SinLindex(\@List,$Str [,$offset [,$CaseInsensitive]]); 7319 # Searches for an exact string in a list. 7320 # 7321 # This is similar to RinLindex except that it searches for elements 7322 # which are exactly equal to $Str (possibly case insensitive). 7323 sub SinLindex { 7324 my($listref,$Str,$offset,$Insensitive)=@_; 7325 my($i,$len,$tmp)=(); 7326 $len=$#$listref; 7327 return -2 if ($len<0 or ! $Str); 7328 return -1 if (&Index_First(\$offset,$len)); 7329 $Str=uc($Str) if ($Insensitive); 7330 for ($i=$offset; $i<=$len; $i++) { 7331 $tmp=$$listref[$i]; 7332 $tmp=uc($tmp) if ($Insensitive); 7333 return $i if ($tmp eq $Str); 7334 } 7335 return -1; 7336 } 7337 7338 sub Index_First { 7339 my($offsetref,$max)=@_; 7340 $$offsetref=0 if (! $$offsetref); 7341 if ($$offsetref < 0) { 7342 $$offsetref += $max + 1; 7343 $$offsetref=0 if ($$offsetref < 0); 7344 } 7345 return -1 if ($$offsetref > $max); 7346 return 0; 7347 } 7348 7349 # $File=&CleanFile($file); 7222 # $File=_CleanFile($file); 7350 7223 # This cleans up a path to remove the following things: 7351 7224 # double slash /a//b -> /a/b … … 7353 7226 # leading dot ./a -> a 7354 7227 # trailing slash a/ -> a 7355 sub CleanFile {7228 sub _CleanFile { 7356 7229 my($file)=@_; 7357 7230 $file =~ s/\s*$//; … … 7366 7239 } 7367 7240 7368 # $File= &ExpandTilde($file);7241 # $File=_ExpandTilde($file); 7369 7242 # This checks to see if a "~" appears as the first character in a path. 7370 7243 # If it does, the "~" expansion is interpreted (if possible) and the full … … 7374 7247 # This is Windows/Mac friendly. 7375 7248 # This is efficient. 7376 sub ExpandTilde {7249 sub _ExpandTilde { 7377 7250 my($file)=shift; 7378 7251 my($user,$home)=(); … … 7401 7274 } 7402 7275 7403 # $File= &FullFilePath($file);7276 # $File=_FullFilePath($file); 7404 7277 # Returns the full or relative path to $file (expanding "~" if necessary). 7405 7278 # Returns an empty string if a "~" expansion cannot be interpreted. The 7406 # path does not need to exist. CleanFile is called.7407 sub FullFilePath {7279 # path does not need to exist. _CleanFile is called. 7280 sub _FullFilePath { 7408 7281 my($file)=shift; 7409 7282 my($rootpat) = '^/'; #default pattern to match absolute path 7410 7283 $rootpat = '^(\\|/|([A-Za-z]:[\\/]))' if ($OS eq 'Windows'); 7411 $file= &ExpandTilde($file);7284 $file=_ExpandTilde($file); 7412 7285 return "" if (! $file); 7413 return &CleanFile($file);7414 } 7415 7416 # $Flag= &CheckFilePath($file [,$mode]);7286 return _CleanFile($file); 7287 } 7288 7289 # $Flag=_CheckFilePath($file [,$mode]); 7417 7290 # Checks to see if $file exists, to see what type it is, and whether 7418 7291 # the script can access it. If it exists and has the correct mode, 1 … … 7429 7302 # All characters in $mode which do not correspond to valid tests are 7430 7303 # ignored. 7431 sub CheckFilePath {7304 sub _CheckFilePath { 7432 7305 my($file,$mode)=@_; 7433 7306 my($test)=(); 7434 $file= &FullFilePath($file);7307 $file=_FullFilePath($file); 7435 7308 $mode = "" if (! defined $mode); 7436 7309 … … 7464 7337 #&& 7465 7338 7466 # $Path= &FixPath($path [,$full] [,$mode] [,$error]);7339 # $Path=_FixPath($path [,$full] [,$mode] [,$error]); 7467 7340 # Makes sure that every directory in $path (a colon separated list of 7468 7341 # directories) appears as a full path or relative path. All "~" … … 7482 7355 # 7483 7356 # The corrected path is returned. 7484 sub FixPath {7357 sub _FixPath { 7485 7358 my($path,$full,$mode,$err)=@_; 7486 7359 local($_)=""; … … 7502 7375 # Expand path 7503 7376 if ($full) { 7504 $_= &FullFilePath($_);7377 $_=_FullFilePath($_); 7505 7378 } else { 7506 $_= &ExpandTilde($_);7379 $_=_ExpandTilde($_); 7507 7380 } 7508 7381 if (! $_) { … … 7512 7385 7513 7386 # Check mode 7514 if (! $mode or &CheckFilePath($_,$mode)) {7387 if (! $mode or _CheckFilePath($_,$mode)) { 7515 7388 $path .= $Cnf{"PathSep"} . $_; 7516 7389 } else { … … 7523 7396 #&& 7524 7397 7525 # $File= &SearchPath($file,$path [,$mode] [,@suffixes]);7398 # $File=_SearchPath($file,$path [,$mode] [,@suffixes]); 7526 7399 # Searches through directories in $path for a file named $file. The 7527 7400 # full path is returned if one is found, or an empty string otherwise. 7528 7401 # The file may exist with one of the @suffixes. The mode is checked 7529 # similar to &CheckFilePath.7402 # similar to _CheckFilePath. 7530 7403 # 7531 7404 # The first full path that matches the name and mode is returned. If none 7532 7405 # is found, an empty string is returned. 7533 sub SearchPath {7406 sub _SearchPath { 7534 7407 my($file,$path,$mode,@suff)=@_; 7535 7408 my($f,$s,$d,@dir,$fs)=(); 7536 $path= &FixPath($path,1,"r");7409 $path=_FixPath($path,1,"r"); 7537 7410 @dir=split(/$Cnf{"PathSep"}/,$path); 7538 7411 foreach $d (@dir) { 7539 7412 $f="$d/$file"; 7540 7413 $f=~ s|//|/|g; 7541 return $f if ( &CheckFilePath($f,$mode));7414 return $f if (_CheckFilePath($f,$mode)); 7542 7415 foreach $s (@suff) { 7543 7416 $fs="$f.$s"; 7544 return $fs if ( &CheckFilePath($fs,$mode));7417 return $fs if (_CheckFilePath($fs,$mode)); 7545 7418 } 7546 7419 } … … 7548 7421 } 7549 7422 7550 # @list= &ReturnList($str);7423 # @list=_ReturnList($str); 7551 7424 # This takes a string which should be a comma separated list of integers 7552 7425 # or ranges (5-7). It returns a sorted list of all integers referred to … … 7554 7427 # 7555 7428 # Negative integers are also handled. "-2--1" is equivalent to "-2,-1". 7556 sub ReturnList {7429 sub _ReturnList { 7557 7430 my($str)=@_; 7558 7431 my(@ret,@str,$from,$to,$tmp)=(); … … 7577 7450 7578 7451 1; 7452 # Local Variables: 7453 # mode: cperl 7454 # indent-tabs-mode: nil 7455 # cperl-indent-level: 3 7456 # cperl-continued-statement-offset: 2 7457 # cperl-continued-brace-offset: 0 7458 # cperl-brace-offset: 0 7459 # cperl-brace-imaginary-offset: 0 7460 # cperl-label-offset: -2 7461 # End: -
trunk/Cocoa/Pester/Source/Pester.xcodeproj/project.pbxproj
r595 r618 9 9 /* Begin PBXBuildFile section */ 10 10 E12CBFD310CC310800159E88 /* NJRMenuSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = E12CBFD210CC310800159E88 /* NJRMenuSlider.m */; }; 11 E14AFF2F11357B6100DC7922 /* Manip in Resources */ = {isa = PBXBuildFile; fileRef = E14AFF2C11357B6100DC7922 /* Manip */; }; 12 E14AFF3011357B6500DC7922 /* Manip in Copy Perl Modules */ = {isa = PBXBuildFile; fileRef = E14AFF2C11357B6100DC7922 /* Manip */; }; 11 13 E15044670CFCDC7E00DE47E9 /* NJRValidatingField.m in Sources */ = {isa = PBXBuildFile; fileRef = E15044660CFCDC7E00DE47E9 /* NJRValidatingField.m */; }; 12 14 E17562620CF8C50B00FC5057 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E17562610CF8C50B00FC5057 /* Sparkle.framework */; }; … … 158 160 files = ( 159 161 E17CA9AB0CF7F8CB00018B34 /* Manip.pm in Copy Perl Modules */, 162 E14AFF3011357B6500DC7922 /* Manip in Copy Perl Modules */, 160 163 ); 161 164 name = "Copy Perl Modules"; … … 194 197 E145383E043A1DB200050002 /* NJRHotKeyManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJRHotKeyManager.h; sourceTree = "<group>"; }; 195 198 E145383F043A1DB200050002 /* NJRHotKeyManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NJRHotKeyManager.m; sourceTree = "<group>"; }; 199 E14AFF2C11357B6100DC7922 /* Manip */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Manip; sourceTree = "<group>"; }; 196 200 E14DB31203B8038300000028 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; }; 197 201 E14DEC820438969400050002 /* NJRHotKeyFieldCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NJRHotKeyFieldCell.h; sourceTree = "<group>"; }; … … 528 532 children = ( 529 533 E17CA9A90CF7F8C200018B34 /* Manip.pm */, 534 E14AFF2C11357B6100DC7922 /* Manip */, 530 535 E19CC53D0CFDE48C0079DCFC /* ParseDate.h */, 531 536 E19CC53E0CFDE48C0079DCFC /* ParseDate.m */, … … 848 853 E1B11F3D0CF5F30F004975AA /* Volume 1.png in Resources */, 849 854 E1B11F3E0CF5F30F004975AA /* Volume.nib in Resources */, 855 E14AFF2F11357B6100DC7922 /* Manip in Resources */, 850 856 ); 851 857 runOnlyForDeploymentPostprocessing = 0;
Note:
See TracChangeset
for help on using the changeset viewer.