<?php
$daysInMonth = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
$errors = array();
for ($year = 1500; $year < 2000; $year++) {
for ($month = 1; $month <= 12; $month++) {
$monthErrors = 0;
for ($day = 1; $day < $daysInMonth[$month]; $day++) {
$baseString = sprintf("%4d-%02d-%02d 00:00:00", $year, $month, $day);
$timestamp = strtotime($baseString);
$roundTrip = date("Y-m-d H:i:s", $timestamp);
if ($baseString !== $roundTrip) {
$errors[] = "$baseString ($timestamp) $roundTrip";
$monthErrors++;
if ($monthErrors > 10) {
break 2;
}
}
}
}
}
$resolvedErrors = array();
if (count($errors) > 50) {
$errorCount = count($errors);
$delta = $errorCount / 50.0;
$currentIndex = 0;
do {
$resolvedErrors[$currentIndex] = $errors[floor($currentIndex)];
$currentIndex += $delta;
} while ($currentIndex < $errorCount);
} else {
$resolvedErrors = $errors;
}
echo implode("\n", $resolvedErrors);
preferences:
35.41 ms | 402 KiB | 5 Q