Skip to content

Commit

Permalink
Item1104: port LocalTimePlugin
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/LocalTimePlugin@2545 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Feb 20, 2009
1 parent 1ca3f04 commit 91687cd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
@@ -1,17 +1,24 @@
%META:TOPICINFO{author="ProjectContributor" date="1057159140" format="1.0" version="1.2"}%
---+ <nop>%TOPIC%

LocalTimePlugin is kind-of rewrite of LocalCityTimePlugin. I was unsatisfied with LocalCityTimePlugin (it has to connect to an external site to get the local time for a given city), so I 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.
LocalTimePlugin is kind-of rewrite of LocalCityTimePlugin.
I was unsatisfied with LocalCityTimePlugin (it has to connect to an external site to get the local time for a given city),
so I 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.

---++ Syntax Rules

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

* see http://www.twinsun.com/tz/tz-link.htm for more information

* 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
* =dateGMT= must be a datetime string that Foswiki can parse (see Foswiki::Time::parseTime), but assumes GMT
* 31 Dec 2001 - 23:59
* 2001/12/31 23:59:59
* 2001.12.31.23.59.59
Expand All @@ -21,7 +28,7 @@ Add a %<nop>LOCALTIME% tag to your text to show the current time. You can specif
* 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/%SYSTEMWEB%/Macros#VarGMTIME
* =format= is the same as for the format specifier in %SYSTEMWEB%/Macros#VarGMTIME
* fromtopic="web.topic" - the plugin tries to use the timezone set in the variable TIMEZONE on the topic selected

---++ Examples
Expand All @@ -36,8 +43,8 @@ This plugin can be used in combination with the CalendarPlugin, to get a localti

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

to add a TWikiIrcMeeting add a line like
<verbatim> * %<nop>LOCALTIME{"Australia/Sydney" dateGMT="6 Mar 2006 - 15:39" format="$day $month"}% - TWikiIrcMeeting=
to add a IrcMeeting add a line like
<verbatim> * %<nop>LOCALTIME{"Australia/Sydney" dateGMT="6 Mar 2006 - 15:39" format="$day $month"}% - IrcMeeting=
</verbatim>

you can even define a USER Variable on your UserTopic, that sets a TimeZone variable, and replace the hardcoded Timezone with that variable.
Expand All @@ -55,34 +62,34 @@ you can even define a USER Variable on your UserTopic, that sets a TimeZone vari

---++ 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.
__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 Foswiki 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 ==%TOPIC%.zip== in your twiki installation directory. Content:
* Unzip ==%TOPIC%.zip== in your Foswiki installation directory. Content:
| *File:* | *Description:* |
| ==data/System/%TOPIC%.txt== | Plugin topic |
| ==data/System/%TOPIC%.txt,v== | Plugin topic repository |
| ==lib/Foswiki/Plugins/%TOPIC%.pm== | Plugin Perl module |
* (Dakar) Visit =configure= in your TWiki installation, and enable the plugin in the {Plugins} section.
* Visit =configure= in your Foswiki 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) |
| Plugin Author: | TWiki:Main.NathanOllerenshaw & Foswiki:Main.SvenDowideit |
| Plugin Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 05 Mar 2006: | SvenDowideit@WikiRing.com - updated to use TWiki04 registerHandler, added format= and dateGMT parameters |
| 20 Feb 2009: | port to Foswiki |
| 05 Mar 2006: | SvenDowideit@WikiRing.com - updated to use 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://foswiki.org/Extensions/%TOPIC% |
| Feedback: | http://foswiki.org/Extensions/%TOPIC%Dev |

__Related Topics:__ %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences, [[%SYSTEMWEB%.Plugins][Plugins]]

-- TWiki:Main/NathanOllerenshaw - 02 Jul 2003
-- TWiki:Main/SvenDowideit - 06 Mar 2006
-- Foswiki:Main/SvenDowideit - 06 Mar 2006
8 changes: 4 additions & 4 deletions lib/Foswiki/Plugins/LocalTimePlugin.pm
Expand Up @@ -3,11 +3,11 @@
# Copyright (C) 2000-2003 Andrea Sterbini, a.sterbini@flashnet.it
# Copyright (C) 2001-2003 Peter Thoeny, peter@thoeny.com
# Copyright (C) 2003 Nathan Ollerenshaw, chrome@stupendous.net
# Copyright (C) 2006 Sven Dowideit, SvenDowideit@WikiRing.com
# Copyright (C) 2006-2009 Sven Dowideit, SvenDowideit@WikiRing.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
Expand All @@ -28,7 +28,7 @@ use vars qw(
$debug $exampleCfgVar $timezone
);

# This should always be $Rev$ so that TWiki can determine the checked-in
# This should always be $Rev$ so that Foswiki can determine the checked-in
# status of the plugin. It is used by the build automation tools, so
# you should leave it alone.
$VERSION = '$Rev$';
Expand Down Expand Up @@ -105,7 +105,7 @@ sub handleLocalTime {
$formatString ||= '$wday, $day $month $year, $hour:$min:$sec ($tz)';
# my $outputTimeZone ||= $Foswiki::cfg{DisplayTimeValues};

#standard twiki date time formats
#standard foswiki date time formats
if( $formatString =~ /rcs/i ) {
# RCS format, example: "2001/12/31 23:59:59"
$formatString = '$year/$mo/$day $hour:$min:$sec';
Expand Down
2 changes: 1 addition & 1 deletion lib/Foswiki/Plugins/LocalTimePlugin/MANIFEST
@@ -1,2 +1,2 @@
data/Foswiki/LocalTimePlugin.txt NEW
data/System/LocalTimePlugin.txt NEW
lib/Foswiki/Plugins/LocalTimePlugin.pm NEW

0 comments on commit 91687cd

Please sign in to comment.