home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / bug727_1.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  1.0 KB  |  39 lines

  1. <?php
  2. /*
  3.  * Tests for weeksInMonth, february with 4 weeks
  4.  * Monday as 1st day of week
  5.  */
  6. define('DATE_CALC_BEGIN_WEEKDAY', 1);
  7. require_once "Date/Calc.php";
  8.  
  9. /**
  10.  * Test dates from 1970 to 2029
  11.  * Data from: http://www.merlyn.demon.co.uk/wknotest.txt
  12.  * Others usefull datas available from:
  13.  * http://www.merlyn.demon.co.uk/#dat
  14.  */
  15. $datapath = dirname( __FILE__);
  16.  
  17. $failed_test_data   = false;
  18. $dates   = file($datapath . '/weeksinmonth_4_monday.txt');
  19. $cnt     = sizeof($dates);
  20. $valids = array();
  21. for( $i=0;$i<$cnt;$i++ ){
  22.     $parts      = explode('/',$dates[$i]);
  23.     $valids[$parts[0]] = array($parts[1]=>(int)str_replace("\n",'',$parts[2]));
  24. }
  25. unset($dates);
  26. foreach($valids as $year => $months){
  27.     foreach ($months as $month=>$valid_weeks) {
  28.         $calc_weeks = Date_Calc::weeksInMonth($month,$year);
  29.         if($calc_weeks!=$valid_weeks){
  30.             $failed_test_data   = true;
  31.             echo "Bug #727, pass 1: $year/$month failed. Expect:$valid_weeks Got:$calc_weeks\n";
  32.         }
  33.     }
  34. }
  35. if (!$failed_test_data) {
  36.     echo "Bug #727, pass 1: OK\n";
  37. }
  38. ?>
  39.