On Apr 12, 2004, at 13:46, Tim Pritlove wrote:
Can anybody describe how time is actually handled by
MediaWiki?
- where is the current time taken from?
UTC is always used to store times internally and is the default
timezone used for display. Your server should, hopefully, have the
correct time set or this can be wrong. (If using multiple web servers
on one database, as we do for Wikipedia, the web servers should have
their clocks synchronized.)
One exception is the time displayed for signatures (typing ~~~~ in a
page); this will be displayed according to the server's local timezone
setting.
- how does wgLocalTZoffset relate to that time?
Hours plus or minus. CET would be 1, CEST 2. Over here in California
I'd want -7 in summer or -8 otherwise. $wgLocalTZoffset sets the
default for display, and can be overridden in user preferences.
- how is daylight saving time integrated?
It is blissfully ignored. :)
If you want to set the default timezone offset according to local
timezone and handle daylight savings time automatically, you can do
this ugly trick:
$wgLocaltimezone="Europe/Berlin";
$oldtz = getenv("TZ");
putenv("TZ=$wgLocaltimezone");
$wgLocalTZoffset = date("Z") / 3600;
putenv("TZ=$oldtz");
Actually, resetting it probably isn't necessary, I think that's
leftover from before we switched to the proper time functions. This
should do (untested):
$wgLocaltimezone="Europe/Berlin";
putenv("TZ=$wgLocaltimezone");
$wgLocalTZoffset = date("Z") / 3600;
For that matter if your server is already in the local timezone you
want, this might work:
$wgLocalTZoffset = date("Z") / 3600;
I'm not 100% sure offhand how non-integral timezones are handled (there
are half-hour and quarter-hour offsets).
I would expect that I set up my server to provide UTC
and MediaWiki to
handle all time as UTC internally as well. So wgLocalTZoffset is an
offset that is added on output.
On the other hand, shouldn't be this a user setting?
It is. Go into Preferences and select your timezone offset.
-- brion vibber (brion @
pobox.com)