Tags:
create new tag
view all tags

Show Local Time of User

The idea sparked in AlwaysServerTimeZone. TWiki is used by many larger corporations that work in many time zones. Right now TWiki simply shows GMT for the recent Changes. As part of the LocalizationFramework, TWiki could show the times in the local time zone of the user.

That means, the user needs to set her timezone somewhere so that TWiki can convert the change dates to local dates. One obvious solution is to set a preferences variable like TIMEZONE in the user preferences. That way the user can easily change the time zone when travelling to another site.

Another idea is to let a Plugin decide on the timezone. This could be done based on the IP address if you know the address ranges used by different sites, assuming the ranges are divided up by site.

-- PeterThoeny - 06 Jan 2004

On the face of it, whatever the user's time zone is, it needs to get into the code in here:

TWiki.pm:

sub formatTime
{
    my ($epochSeconds, $formatString, $outputTimeZone) = @_;
    my $value = $epochSeconds;

    # use default TWiki format "31 Dec 1999 - 23:59" unless specified
    $formatString = "\$day \$month \$year - \$hour:\$min" unless( $formatString );
    $outputTimeZone = $displayTimeValues unless( $outputTimeZone );

    my( $sec, $min, $hour, $day, $mon, $year, $wday) = gmtime( $epochSeconds );
      ( $sec, $min, $hour, $day, $mon, $year, $wday ) = localtime( $epochSeconds ) if( $outputTimeZone eq "servertime" );

The key is the last two lines. A patch would get the time from a user preference and alter the time array returned according to the users timezone. Doubtless Date::Calc would be enough.

  • Would changing it here have unintended side effects?

-- MartinCleaver - 12 Jul 2004

If I wasn't so attached to my UserCookiePlugin, I'd suggest that this is another reason we should integrate the SmartSessionPlugin, and then store and use that info in conjunction with a %DISPLAYTIME% version of SetTimezoneInTWikiDotCfg

-- SvenDowideit - 21 Jul 2004

Idea re-sparked in UseIsoDates: The need to have localized time for each user. That should be done generically with a user preferences setting.

-- PeterThoeny - 26 Oct 2005

IMHO it would be already of great help to display the word "GMT" for all date/time values as users are used to have their local time displayed unless mentioned otherwise.

-- FerdinandGassauer - 27 Apr 2006

BTW I think it's useful to distinguish two concepts here:

  1. Local time - i.e. date/time in user's timezone - could still be shown in English format.
  2. Localised date-time format - i.e. use the order of day, month and year, and other special characters for the user's locale. Examples include 02.04.2007 (most of Europe), 2007年4月2日 (Japan), 04/02/2007 (US), for 2 Apr 2007.

-- RichardDonkin - 03 Apr 2007

I implemented this functionality in LocalTimePlugin a while back - see %LOCALTIME{fromtopic and we use it to display meeting times in the current user's TIMEZONE.

-- SvenDowideit - 03 Apr 2007

Interesting - however, we really need something in the TWiki core that is session driven so it's per-user like the UserInterfaceInternationalisation stuff, and also hands localisation/I18N of dates.

-- RichardDonkin - 05 Apr 2007

Not session driven, better as a setting in the user preferences. Agreed that this functionality should be in the TWiki core.

-- PeterThoeny - 05 Apr 2007

this is session driven. if you set %LOCALTIME{fromtopic="WIKINAME"

you get the time in the currently logged in user's timezone.

-- SvenDowideit - 05 Apr 2007

It is still a pain that the local time is not displayed site wide, with all occurrences of GMT.

-- ArthurClemens - 21 Aug 2007

Did you know that you can now set TWiki to use the server-local time, site wide? See the servertime dropdown in configure, and AlwaysServerTimeZone.

-- RichardDonkin - 22 Aug 2007

Excellent. So this gem has been hidden for a long time. I've made a short FAQ in HowToDisplayLocalTime.

-- ArthurClemens - 22 Aug 2007

Indeed - we need to get better at writing FAQs and docs, though having a doc model that works better between SVN and TWiki web would help.

-- RichardDonkin - 23 Aug 2007

Edit | Attach | Watch | Print version | History: r19 < r18 < r17 < r16 < r15 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r19 - 2007-08-23 - RichardDonkin
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.