Page MenuHomePhabricator

strange double-counting with wgLocaltimezone and weekday in signatures
Closed, ResolvedPublic

Description

Author: lowzl

Description:
When $wgLocaltimezone is a large number (i.e. > 6 or < -6), the day of week
which appears in signatures can be off by ±1 day. For example, today at 10:45AM
UTC, Pacific/Honolulu was Wednesday, Europe/France was Thursday, and Asia/Tokyo
was Friday. It appears to result from applying the timezone correction twice,
but I cannot be certain. The date and time is completely unaffected, and the
magic words ({{CURRENTDAYNAME}} etc.) report the correct day of week.

To replicate, set the system time to UTC), and set $wgLocaltimezone to somewhere
near the international dateline (Pacific/Auckland is good, so is
Pacific/Honolulu). Set $wgLanguageCode to ja or another language which includes
the day of the week in the signature.


Version: unspecified
Severity: normal
OS: Linux
Platform: PC

Details

Reference
bz8577

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:32 PM
bzimport set Reference to bz8577.
bzimport added a subscriber: Unknown Object (MLST).

lowzl wrote:

I think I've identified the problem. This affects everything in sprintfDate
which calculates using a UNIX timestamp. There are two possible ways to fix it.

First option: move the call to timeanddate() in Parser.php out of the scope
where TZ is altered:

if ( isset( $wgLocaltimezone ) ) {
$oldtz = getenv( 'TZ' );
putenv( 'TZ='.$wgLocaltimezone );
}
$timestamp = date( 'YmdHis' );
if ( isset( $wgLocaltimezone ) ) {
putenv( 'TZ='.$oldtz );
}
$d = $wgContLang->timeanddate( $timestamp , false, false) .

' (' . date( 'T' ) . ')';

Alternatively, change the calls to date() in Language.php to gmdate(). I'm not
sure which one is more correct, since it isn't stated anywhere whether
sprintfDate() takes UTC timestamp and formats it in accordance to the TZ
environment variable, or if it takes any timestamp and does no timezone adjustment.

Fixed, I hope, in r23017.

{{CURRENT*}} functions now consistently use UTC as intended, while
{{LOCAL*}} functions return local time per server config or $wgLocaltimezone.

Signature dates for Japanese and other languages including weekday now show
the correct day to match the rest of the time in local time.

Previously there was a weird mix, where {{CURRENT*}} sometimes used server local time while {{LOCAL*}} used $wgLocaltimezone, and sometimes either were just borked.