<?php
/*
 * Tests for weeksInMonth, february with 4 weeks
 * Sunday as 1st day of week
 */
define('DATE_CALC_BEGIN_WEEKDAY', 0);
require_once "Date/Calc.php";

/**
 * Test dates from 1970 to 2029
 * Data from: http://www.merlyn.demon.co.uk/wknotest.txt
 * Others usefull datas available from:
 * http://www.merlyn.demon.co.uk/#dat
 */
$datapath = dirname( __FILE__);

$failed_test_data   = false;
$dates   = file($datapath . '/weeksinmonth_4_sunday.txt');
$cnt     = sizeof($dates);
$valids = array();
for( $i=0;$i<$cnt;$i++ ){
    $parts      = explode('/',$dates[$i]);
    $valids[$parts[0]] = array($parts[1]=>(int)str_replace("\n",'',$parts[2]));
}
unset($dates);
foreach($valids as $year => $months){
    foreach ($months as $month=>$valid_weeks) {
        $calc_weeks = Date_Calc::weeksInMonth($month,$year);
        if($calc_weeks!=$valid_weeks){
            $failed_test_data   = true;
            echo "Bug #727, pass 3: $year/$month failed. Expect:$valid_weeks Got:$calc_weeks\n";
        }
    }
}
if (!$failed_test_data) {
	echo "Bug #727, pass 2: OK\n";
}
