Introduced by fixing
Item7676, the
SERVERTIME
variable always returns
GMTIME
.
I had already spotted this when debugging for
Item7705, but regarded it as a minor issue compared to the fact that I can't build
TWiki:Codev.TWikiPersonal
from 6.0.2 (which I would, by the way, like to do to cover
TWiki:Support.SID-02241
), but the issue wasn't placed well there. Since another quirk of the bug has come up in
Item7739, I'm reporting this as a separate issue. In that issue, Jani Hamalainen writes that
Changing from 'servertime' to 'gmtime' ($TWiki::cfg{DisplayTimeValues} = 'gmtime';
) corrects the error however for users wanting to use 'servertime' the plugin will not work. Well... in fact, users wanting to use 'servertime' will spot that they get 'gmtime' anyway.
The reason:
The documentation of
TWiki::Time::formatTime
,
TWiki::Func::formatTime
, and the configuration variable
{DisplayTimeValues}
all restrict the permitted timezone values to
"gmtime"
and
"servertime"
, neither of which are actually
timezones. Before 6.0.2, the implementation had treated all "timezone" values different from
"gmtime"
as equivalent to
"servertime"
which is sloppy, based on the assumption that no other values are permitted anyway. In the current TWiki codebase, a few instances call
TWiki::Time::formatTime
, explicitly requiring
"servertime"
(most notably, the
SERVERTIME
variable). But
"servertime"
is not a valid time zone, so in fact we are setting
$ENV{TZ}
to an invalid timezone value. This, according to the
tzset
system call, results in setting the timezone to UTC, which is exactly what the caller didn't request when he said
SERVERTIME
. Quoting
http://man7.org/linux/man-pages/man3/tzset.3.html
:
- If the TZ variable does not appear in the environment, the system timezone is used. The system timezone is configured by copying, or linking, a file in the tzfile(5) format to /etc/localtime. A timezone database of these files may be located in the system timezone directory (see the FILES section below).
- If the TZ variable does appear in the environment, but its value is empty, or cannot be interpreted using any of the formats specified below, then Coordinated Universal Time (UTC) is used.
--
TWiki:Main/HaraldJoerg
- 2016-08-19
Putting a clean and ideal solution aside, I made SERVERTIME returns server's time rather than GMTIME by having TWIki::Time::formatTime() recognize 'servertime' as a special $outputTimeZone value.
--
TWiki:Main.HideyoImazu
- 2017-05-31