Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
define('CLI_SCRIPT', true);
require_once('config.php');
function check($year, $day) {
$calendartype = \core_calendar\type_factory::get_calendar_instance();
$timestamp = $calendartype->convert_to_timestamp(
$year,
1,
$day
);
$time = $calendartype->timestamp_to_date_array($timestamp);
$prevmonthyear = $calendartype->get_prev_month($time['year'], $time['mon']);
$prev = $calendartype->convert_to_timestamp(
$prevmonthyear[1],
$prevmonthyear[0],
1
);
$prevtime = $calendartype->timestamp_to_date_array($prev);
$nextmonthyear = $calendartype->get_next_month($time['year'], $time['mon']);
$next = $calendartype->convert_to_timestamp(
$nextmonthyear[1],
$nextmonthyear[0],
1
);
$nexttime = $calendartype->timestamp_to_date_array($next);
if ($time['mon'] == 1) {
if ($prevtime['mon'] != 12) {
echo "== " . __LINE__ . " ======================================================================\n";
print_object($prevtime);
print_object($time);
print_object($nexttime);
echo "============================================================================\n";
}
} else {
if ($time['mon'] != $prevtime['mon'] + 1) {
echo "== " . __LINE__ . " ======================================================================\n";
print_object($prevtime);
print_object($time);
print_object($nexttime);
echo "============================================================================\n";
die;
}
}
if ($time['mon'] == 12) {
if ($nexttime['mon'] != 1) {
echo "== " . __LINE__ . " ======================================================================\n";
print_object($prevtime);
print_object($time);
print_object($nexttime);
echo "============================================================================\n";
}
} else {
if ($time['mon'] != $nexttime['mon'] - 1) {
echo "== " . __LINE__ . " ======================================================================\n";
print_object($prevtime);
print_object($time);
print_object($nexttime);
echo "============================================================================\n";
}
}
}
for ($year = 1970; $year < 2200; $year++) {
echo "\n == {$year} ==\n\n";
for ($day = 1; $day < 366; $day++) {
check($year, $day);
}
}
echo "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.