function SimpletestUnitTestExampleTestCase::testCalendarSystemsConversion in Calendar Systems 8
Same name and namespace in other branches
- 6.3 simpletest_calendar_systems.test \SimpletestUnitTestExampleTestCase::testCalendarSystemsConversion()
- 6 simpletest_calendar_systems.test \SimpletestUnitTestExampleTestCase::testCalendarSystemsConversion()
- 7.3 simpletest_calendar_systems.test \SimpletestUnitTestExampleTestCase::testCalendarSystemsConversion()
- 7 simpletest_calendar_systems.test \SimpletestUnitTestExampleTestCase::testCalendarSystemsConversion()
- 7.2 simpletest_calendar_systems.test \SimpletestUnitTestExampleTestCase::testCalendarSystemsConversion()
File
- ./
simpletest_calendar_systems.test, line 25
Class
Code
function testCalendarSystemsConversion() {
$message = "Jalali Date To Gregorian Conversion does not work properly";
$result = true;
$calendar = calendar_systems_get_calendar_instance();
for ($y = 1300; $y <= 1400; $y++) {
for ($m = 1; $m <= 12; $m++) {
for ($d = 1; $d <= $calendar
->daysInMonth($m - 1, 'jalali'); $d++) {
$fadate = $y . '/' . str_pad($m, 2, "0", STR_PAD_LEFT) . '/' . str_pad($d, 2, "0", STR_PAD_LEFT);
$_infoArray_fadate = split('/', $fadate);
$_infoArray_fadate = array(
'year' => $_infoArray_fadate[0],
'month' => $_infoArray_fadate[1],
'day' => $_infoArray_fadate[2],
);
$timestamp_birthdaf = $calendar
->infoArrayToTimestamp($_infoArray_fadate);
$birthdaf_val = date('Y-m-d', $timestamp_birthdaf);
$birthdaf_val_timestamp = $calendar
->strToTimestamp($birthdaf_val);
$check_date = format_date($birthdaf_val_timestamp, 'custom', 'Y/m/d');
if ($fadate != $check_date) {
$result = false;
$message .= " \n {$fadate} : {$check_date}";
//print($fadate);
//echo '<br />';
//print($check_date);
//echo '<br />';
//echo '<hr />';
}
}
}
}
$this
->assertTrue($result, $message);
}