Added workaround for year detection for RFC 3164 like timestamps. This also solves rare new year conditions

This commit is contained in:
Andre Lorbach 2008-12-04 16:26:18 +01:00
parent 673b1863df
commit 05795f40b9

View File

@ -1071,7 +1071,15 @@ function GetEventTime($szTimStr)
if ( preg_match("/(...) ([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) ) if ( preg_match("/(...) ([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
{ {
// RFC 3164 typical timestamp // RFC 3164 typical timestamp
$eventtime[EVTIME_TIMESTAMP] = mktime($out[3], $out[4], $out[5], GetMonthFromString($out[1]), $out[2]); $eventtime[EVTIME_TIMESTAMP] = mktime($out[3], $out[4], $out[5], GetMonthFromString($out[1]), $out[2], date("Y") );
// If the current time is
if ( $eventtime[EVTIME_TIMESTAMP] > time() )
{
// rare case on new year only!
$eventtime[EVTIME_TIMESTAMP] = mktime($out[3], $out[4], $out[5], GetMonthFromString($out[1]), $out[2], date("Y")-1 );
}
$eventtime[EVTIME_TIMEZONE] = date_default_timezone_get(); // WTF TODO! $eventtime[EVTIME_TIMEZONE] = date_default_timezone_get(); // WTF TODO!
$eventtime[EVTIME_MICROSECONDS] = 0; $eventtime[EVTIME_MICROSECONDS] = 0;