• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7700 for generic doc work for TWiki-6.0.2. Use View topic Item7703 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item7752: SERVERTIME is always identical to GMTIME

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Low Waiting for Release   patch  

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


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

Summary SERVERTIME is always identical to GMTIME
ReportedBy TWiki:Main.HaraldJoerg
Codebase ~twiki4, 6.0.2
SVN Range TWiki-6.0.2-trunk, Fri, 29 Jul 2016, build 30222
AppliesTo Engine

Priority Low
CurrentState Waiting for Release

Checkins TWikirev:30347 TWikirev:30348
TargetRelease patch

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r2 - 2017-05-31 - HideyoImazu
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback