• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 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.

Item7811: SERVERTIME to be in local time; DISPLAYTIME and log time stamps to observe {DisplayTimeValues}

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine TWiki Normal Closed   patch 6.1.0

Edit Form Data

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


Display of times in TWiki metacode

Should these matters be platform related, my platform is 'CentOS Linux release 7.3.1611 (Core)'

Problem description

  • Tested using the following TWiki metacode with $TWiki::cfg{DisplayTimeValues} = 'localtime'; in LocalSite.cfg.


  • Result: I get times rendered in GMT for the 3 above times. This is correct for GMTIME but not for DISPLAYTIME and maybe not for SERVERTIME?

Problem analysis

The following code in sub formatTime {} in lib/TWiki/Time.pm is relevant.

   210      } else {
   211          my $tzSave;
   212          if ( $outputTimeZone ) {
   213              $tzSave = $ENV{TZ};
   214              $ENV{TZ} = $outputTimeZone;
   215              tzset();
   216          }

Commenting out line 214 & 215 as a hack fixes the problem.

  • Result: I get times rendered in BST for DISPLAYTIME and SERVERTIME and in GMT for GMTIME which is correct.

If not set explicitly in the code $outputTimeZone is set to $TWiki::cfg{DisplayTimeValues} from LocalSite.cfg. Looking at the man page for tzset on my system suggests localtime (or gmtime as suggested in lib/TWiki.spec) is not a valid value for this environment variable, which is intended to code an explicit/geographical timezone spec, eg. Europe/London.

  • Uncommented/restored the code in lib/TWiki/Time.pm and changed LocalSite.cfg item to read $TWiki::cfg{DisplayTimeValues} = ':/etc/localtime'; where /etc/localtime -> /usr/share/zoneinfo/Europe/London on my system.

  • Result: I get times rendered in BST for DISPLAYTIME and in GMT for SERVERTIME and GMTIME which is better.

  • Conclusion: This is acceptable but is this the intended behaviour? Maybe the entry in lib/TWiki.spec needs amending?

Display of times in TWiki logs (eg. data/log201705.txt and data/debug.txt)

Problem description

The logs are always timestamped in GMT. Looking at the code (see below) this seems to be intended. At least on the Unix systems I have administered most things (syslog,Apache etc.) always log in local time, which to my mind makes the TWiki logs slightly confusing.

Problem analysis

The following code in sub _writeReport{} in lib/TWiki.pm is relevant.

  2354  sub _writeReport {
  2355      my ( $this, $log, $message ) = @_;
  2357      if ( $log ) {
  2358          require TWiki::Time;
  2359          my $time =
  2360            TWiki::Time::formatTime( time(), '$year$mo', 'gmtime');
  2361          $log =~ s/%DATE%/$time/go;
  2362          $time = TWiki::Time::formatTime( time(), '$year-$mo-$day - $hour:$min:$sec', 'gmtime' );

Replacing both instances of 'gmtime' with undef makes the formatTime() call use the timezone value $TWiki::cfg{DisplayTimeValues} specified in LocalSite.cfg, which as changed above makes the logs timestamps render in BST. Could this (being able to set the timezone for logs) be considered as a feature request for future TWiki releases? I notice there are many other calls to formatTime() and other functions within the TWiki code which specify gmtime as an argument and I can see that for certain internal uses this makes sense. Maybe a more holistic approach to timezone handling rather than the two issues I've brought up is needed...

-- TWiki:Main/TomCrane - 2017-05-16

Thanks for the thorough description of the symptoms and analysis. It seems that this item is closely related to Item7752 (same root cause, different observations). I fully agree with Maybe a more holistic approach to timezone handling [...] is needed.

-- TWiki:Main.HaraldJoerg - 2017-05-18

TWiki::_writeReport() now omits the third argument of TWiki::TIme::formatTime(). TWikibug:Item7752 is already taken care of. So you can have time stamps in log files in local time if you set $TWiki::cfg{DisplayTimeValues} "servertime".

-- TWiki:Main.HideyoImazu - 2017-06-01

Summary SERVERTIME to be in local time; DISPLAYTIME and log time stamps to observe {DisplayTimeValues}
ReportedBy TWiki:Main.TomCrane
Codebase ~twiki4, 6.0.2
SVN Range TWiki-6.0.2-trunk, Fri, 07 Apr 2017, build 30318
AppliesTo Engine
Component TWiki
Priority Normal
CurrentState Closed

Checkins TWikirev:30349 TWikirev:30350
TargetRelease patch
ReleasedIn 6.1.0
Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r10 - 2018-07-17 - PeterThoeny
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback