function lastday($y, $m) { $last = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if (LeapYear($y)) { $last[1] = 29; } return $last[$m - 1]; }
$errors['date'] = "Error: Since when are there non-numeric years?"; } elseif ($date1[2] < 2007 || $date2[2] < 2007) { $errors['date'] = "Error: Stop trying to search for shit from before Weedhat was even conceived."; } elseif ($maxdays[$date1[0]] < $date1[1]) { if ($date1[0] != "february") { $errors['date'] = "Error: That month doesn't have that many days."; } else { if (!LeapYear($date1[2]) || $date1[1] > 29) { $errors['date'] = "Error: That month doesn't have that many days."; } } } elseif ($maxdays[$date2[0]] < $date2[1]) { if ($date2[0] != "february") { $errors['date'] = "Error: That month doesn't have that many days."; } else { if (!LeapYear($date2[2]) || $date2[1] > 29) { $errors['date'] = "Error: That month doesn't have that many days."; } } } else { if (DateToTimestamp("{$date1['0']} {$date1['1']} {$date1['2']}") < DateToTimestamp("{$date2['0']} {$date2['1']} {$date2['2']}")) { $querystr .= "date:{$date2['0']}_{$date2['1']}_{$date2['2']}-{$date1['0']}_{$date1['1']}_{$date1['2']};"; } else { $querystr .= "date:{$date1['0']}_{$date1['1']}_{$date1['2']}-{$date2['0']}_{$date2['1']}_{$date2['2']};"; } } } else { if (!is_numeric($date1[0]) || !is_numeric($date2[0])) { $errors['date'] = "Error: Invalid date.<br /><br />Dates must use the following syntax:<br/>1. <b>(Number) (Hours/Days/Weeks/Months) Ago</b><br />2. <b>(Month) (Numeric Date) (Numeric Year)</b><br />3. <b>(Unix Timestamp)</b>"; } elseif (!in_array($date1[1], $units) || !in_array($date2[1], $units)) { $errors['date'] = "Error: Invalid date.<br /><br />Dates must use the following syntax:<br/>1. <b>(Number) (Hours/Days/Weeks/Months) Ago</b><br />2. <b>(Month) (Numeric Date) (Numeric Year)</b><br />3. <b>(Unix Timestamp)</b>";