| Index: trunk/extensions/ParserFunctions/ParserFunctions_body.php |
| — | — | @@ -433,9 +433,15 @@ |
| 434 | 434 | public static function time( $parser, $format = '', $date = '', $language = '', $local = false ) { |
| 435 | 435 | global $wgLocaltimezone; |
| 436 | 436 | self::registerClearHook(); |
| 437 | | - if ( isset( self::$mTimeCache[$format][$date][$language][$local] ) ) { |
| 438 | | - return self::$mTimeCache[$format][$date][$language][$local]; |
| | 437 | + if ( $date === '' ) { |
| | 438 | + $cacheKey = $parser->getOptions()->getTimestamp(); |
| | 439 | + $date = wfTimestamp( TS_ISO_8601, $cacheKey ); |
| | 440 | + } else { |
| | 441 | + $cacheKey = $date; |
| 439 | 442 | } |
| | 443 | + if ( isset( self::$mTimeCache[$format][$cacheKey][$language][$local] ) ) { |
| | 444 | + return self::$mTimeCache[$format][$cacheKey][$language][$local]; |
| | 445 | + } |
| 440 | 446 | |
| 441 | 447 | # compute the timestamp string $ts |
| 442 | 448 | # PHP >= 5.2 can handle dates before 1970 or after 2038 using the DateTime object |
| — | — | @@ -456,13 +462,9 @@ |
| 457 | 463 | } |
| 458 | 464 | |
| 459 | 465 | # Parse date |
| 460 | | - if ( $date !== '' ) { |
| 461 | | - # UTC is a default input timezone. |
| 462 | | - $dateObject = new DateTime( $date, $utc ); |
| 463 | | - } else { |
| 464 | | - # use current date and time |
| 465 | | - $dateObject = new DateTime( 'now', $utc ); |
| 466 | | - } |
| | 466 | + # UTC is a default input timezone. |
| | 467 | + $dateObject = new DateTime( $date, $utc ); |
| | 468 | + |
| 467 | 469 | # Set output timezone. |
| 468 | 470 | if ( $local ) { |
| 469 | 471 | if ( isset( $wgLocaltimezone ) ) { |
| — | — | @@ -503,7 +505,7 @@ |
| 504 | 506 | } |
| 505 | 507 | } |
| 506 | 508 | } |
| 507 | | - self::$mTimeCache[$format][$date][$language][$local] = $result; |
| | 509 | + self::$mTimeCache[$format][$cacheKey][$language][$local] = $result; |
| 508 | 510 | return $result; |
| 509 | 511 | } |
| 510 | 512 | |