Last modified: 2008-02-09 20:41:40 UTC
At the beginning of function pstPass2 in Parser.php we have the following code. Effective as of around revision 30106: if ( isset( $wgLocaltimezone ) ) { $oldtz = getenv( 'TZ' ); putenv( 'TZ='.$wgLocaltimezone ); } $d = $wgContLang->timeanddate( $this->mOptions->getTimestamp(), false, false) . ' (' . date( 'T' ) . ')'; if ( isset( $wgLocaltimezone ) ) { putenv( 'TZ='.$oldtz ); } The issue with this is that if $wgLocaltimezone is set, $this->mOptions->getTimestamp() seems to return a cached UTC timestamp, while date( 'T' ) returns a the TimeZone abbreviation coordinated with $wgLocaltimezone. Example, my $wgLocaltimezone is set to "America/Chicago" if I used ~~~~~ in a page at 23:19 Central today (27 January), my timestamp is reported as "05:19, 28 January 2008 (CST)" An off the cuff suggestion for solving this is the following: if ( isset( $wgLocaltimezone ) ) { $oldtz = getenv( 'TZ' ); putenv( 'TZ='.$wgLocaltimezone ); $dtz = date( 'YmdHis' ); } else { $dtz = $this->mOptions->getTimestamp(); } $d = $wgContLang->timeanddate( $dtz , false, false) . ' (' . date( 'T' ) . ')'; if ( isset( $wgLocaltimezone ) ) { putenv( 'TZ='.$oldtz ); }
Thinking about this more, could it be a better option to create and store a $mLocalTimestamp on the ParserOptions which is set at the same time as the standard timestamp (perhaps add a $local parameter on the getTimestamp() call also)? But I don't know (offhand) where else a LocalTimestamp would be used so it may not be justified to calculate and store both.
Looking into it one step further, the timeanddate function in Language.php called here seems to make the appropriate adjustment if if passed with the 2nd parameter being true: (so long as $wgLocalTZoffset is set properly) As $d is only used in putting together signatures, so I would bet that the following would be the best option: $d = $wgContLang->timeanddate( $this->mOptions->getTimestamp(), isset( $wgLocaltimezone ) , false) . ' (' . date( 'T' ) . ')';
Should be fixed in r30766, based on the earlier suggestion above. (Passing true as the 2nd parameter to timeanddate() doesn't work right if the user has set a different timezone offset in their preferences.)