Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@andrewnicols
Created October 31, 2017 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewnicols/6dcb1811ecba88bdd89b5a1ba24ec7b0 to your computer and use it in GitHub Desktop.
Save andrewnicols/6dcb1811ecba88bdd89b5a1ba24ec7b0 to your computer and use it in GitHub Desktop.
<?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