summaryrefslogtreecommitdiffstats
path: root/scripts/timezones.pl
diff options
context:
space:
mode:
authorJari Matilainen2015-11-24 16:06:16 +0100
committerJari Matilainen2015-11-24 16:06:16 +0100
commit4775c0a652fab0608acc57788a060f390dacea60 (patch)
treedde5002e5903f1fc49aff1dcec27049dc76554b7 /scripts/timezones.pl
parent1d85c4160eb53dfe2293dbc09926679d9b9d4b19 (diff)
downloadscripts.irssi.org-4775c0a652fab0608acc57788a060f390dacea60.tar.bz2
Initial commit
Diffstat (limited to 'scripts/timezones.pl')
-rw-r--r--scripts/timezones.pl23
1 files changed, 16 insertions, 7 deletions
diff --git a/scripts/timezones.pl b/scripts/timezones.pl
index 9b383d8..65e9ebe 100644
--- a/scripts/timezones.pl
+++ b/scripts/timezones.pl
@@ -8,18 +8,18 @@
# or add it to an existing one with
# /statusbar window add timezones (window is an exaple, see /statusbar and /help statusbar for comprehensive help)
-use strict;
-use vars qw($VERSION %IRSSI);
-$VERSION = "0.1";
+$VERSION = "0.2";
%IRSSI = (
authors => "Jari Matilainen",
- contact => "irc: vague`\@freenode",
+ contact => 'vague!#irssi@freenode on irc',
name => "timezones",
description => "timezones displayer",
license => "Public Domain",
- url => "http://vague.se"
+ url => "http://gplus.to/vague",
+ changed => "Tue 24 November 16:00:00 CET 2015",
);
+use strict;
use Irssi::TextUI;
use DateTime;
@@ -36,8 +36,17 @@ sub timezones {
foreach(@timezones) {
if(length($result)) { $result .= $div; }
my ($nick, $timezone) = split /:/, $_;
- my $now = DateTime->now(time_zone => $timezone);
- $result .= $nick . ": " . $now->strftime("$datetime");
+ my $now;
+ eval {
+ $now = DateTime->now(time_zone => "$timezone") or die $!;
+ };
+
+ if($@) {
+ $result .= $nick . ": INVALID";
+ }
+ else {
+ $result .= $nick . ": " . $now->strftime("$datetime");
+ }
}
$item->default_handler($get_size_only, undef, $result, 1);