We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
You are here: TWiki> Plugins Web>LocalTimePlugin (24 Jul 2006, SvenDowideit)
Tags:
date_time2Add my vote for this tag create new tag
, view all tags

LocalTimePlugin

LocalTimePlugin is kind-of rewrite of LocalCityTimePlugin. Nathan was unsatisfied with LocalCityTimePlugin (it used to connect to an external site to get the local time for a given city), so Nathan wrote this Plugin to use the system's localtime functions. It works rather well, but doesn't do too much checking right now for a valid code. It won't die horribly if you give it a bad code, it just will give you a random time.

I use it for our systems diary here. Works quite well.

Sven has brought it up to date with TWiki-4, and is slowly adding functionality to it.

Syntax Rules

Add a %LOCALTIME% tag to your text to show the current time. You can specify the location or timezone such as "Asia/Tokyo" or "GMT" with %LOCALTIME{location}%, where location is a location mentioned at http://twiki.org/cgi-bin/xtra/tzdate, or a timezone code such as "JST".

  • The unnamed, or DEFAULT parameter is the timezone to output
  • dateGMT must be a datetime string that TWiki can parse (see Time::TWiki::parseTime), but assumes GMT
    • 31 Dec 2001 - 23:59
    • 2001/12/31 23:59:59
    • 2001.12.31.23.59.59
    • 2001/12/31 23:59
    • 2001.12.31.23.59
    • 2001-12-31T23:59:59Z
    • 2001-12-31T23:59:59+01:00
    • 2001-12-31T23:59Z
    • 2001-12-31T23:59+01:00
  • format is the same as for the format specifier in http://t42p/cgi-bin/DEVELOP/bin/view/TWiki/TWikiVariables#VarGMTIME
  • fromtopic="web.topic" - the plugin tries to use the timezone set in the variable TIMEZONE on the topic selected

Examples

  you type if installed you get
Time in Tokyo now %LOCALTIME{Asia/Tokyo}% %LOCALTIME{Asia/Tokyo}%
Time in London now %LOCALTIME{Europe/London}% %LOCALTIME{Europe/London}%
Time in your TIMEZONE (if you've set the TIMEZONE VAR) now %LOCALTIME{fromtopic="$percntWIKIUSERNAME$percnt"}% %LOCALTIME{fromtopic="$percntWIKIUSERNAME$percnt"}%
05 Apr 2006, 15:43:50 GMT in Sydney/Australia %LOCALTIME{"Australia/Sydney" dateGMT="05 Apr 2006 - 15:43:50"}% %LOCALTIME{"Australia/Sydney" dateGMT="05 Apr 2006 - 15:43:50"}%
05 Apr 2006, 15:43:50 GMT in Sydney/Australia (format as iso) %LOCALTIME{"Australia/Sydney" dateGMT="05 Apr 2006 - 15:43:50" format="iso"}% %LOCALTIME{"Australia/Sydney" dateGMT="05 Apr 2006 - 15:43:50" format="iso"}%

This plugin can be used in combination with the CalendarPlugin, to get a localtime version of your appointments.

Your TWikiAdmin? may need to add this plugin to the pluginsOrder to make sure it evaluates before CalendarPlugin.

to add a TWikiIrcMeeting? add a line like

   * %<nop>LOCALTIME{"Australia/Sydney" dateGMT="6 Mar 2006 - 15:39" format="$day $month"}% - TWikiIrcMeeting=

you can even define a USER Variable on your UserTopic? , that sets a TimeZone? variable, and replace the hardcoded Timezone with that variable.

LocalTimePlugin Global Settings

  • One line description:
    • Set SHORTDESCRIPTION = A plugin to give the current date and time of a particular city/timezone.

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

  • Defaults:
    • Set TIMEZONE = Asia/Tokyo

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.

  • Install the Date::Handler package from CPAN:
    • perl -MCPAN -e 'install Date::Handler'
  • Download the ZIP file from the Plugin web (see below)
  • Unzip LocalTimePlugin.zip in your twiki installation directory. Content:
File: Description:
data/TWiki/LocalTimePlugin.txt Plugin topic
data/TWiki/LocalTimePlugin.txt,v Plugin topic repository
lib/TWiki/Plugins/LocalTimePlugin.pm Plugin Perl module
  • (Dakar) Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.
  • Test if the installation was successful:
    • %LOCALTIME%

Plugin Info

Plugin Author: TWiki:Main.NathanOllerenshaw & TWiki:Main.SvenDowideit
Plugin Version: 23 Jul 2006 (V2.000)
Change History:  
05 Mar 2006: SvenDowideit@WikiRingPLEASENOSPAM.com - updated to use TWiki04 registerHandler, added format= and dateGMT parameters
02 Jul 2003: Initial version
CPAN Dependencies: Date::Handler
Other Dependencies: none
Perl Version: 5.005
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/LocalTimePlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/LocalTimePluginDev

Related Topics: TWikiPreferences, TWikiPlugins

-- TWiki:Main/NathanOllerenshaw - 02 Jul 2003 -- TWiki:Main/SvenDowideit - 23 July 2006

Topic attachments
I Attachment Action Size Date Who Comment
elsemd5 LocalTimePlugin.md5 manage 0.2 K 23 Jul 2006 - 05:17 SvenDowideit md5 checksums
ziptgz LocalTimePlugin.tgz manage 11.3 K 23 Jul 2006 - 05:17 SvenDowideit untar, correct the permissions, and run the installer script, if there is one
zipzip LocalTimePlugin.zip manage 12.7 K 23 Jul 2006 - 05:18 SvenDowideit unzip, correct the permissions, and run the installer script, if there is one
Topic revision: r10 - 24 Jul 2006 - 03:49:35 - SvenDowideit
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback