aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Plugin/Timezone.pm17
1 files changed, 13 insertions, 4 deletions
diff --git a/Plugin/Timezone.pm b/Plugin/Timezone.pm
index 6450a6d..6380465 100644
--- a/Plugin/Timezone.pm
+++ b/Plugin/Timezone.pm
@@ -30,14 +30,23 @@ sub time {
return "Syntax: time [nick]" unless @arguments <= 1;
my $nick = $arguments[0] || $requester;
+
my ($case_nick) = grep {/^$nick$/i} @known_zones;
+ my $tz;
if ($case_nick) {
+ $tz = $config->{timezone}->{$case_nick};
+ } else {
+ $tz = $nick;
+ }
+
+ eval {
my $d = DateTime->now();
- $d->set_time_zone($config->{timezone}->{$case_nick});
+ $d->set_time_zone($tz);
my $timestr = $d->strftime("%H:%M on %a %d %b, %Y (%Z)");
- return "$nick\'s clock reads $timestr";
- } else {
- return "$requester: I don't know what timezone $nick is in";
+ return "$nick\'s clock reads $timestr" if $case_nick;
+ return "Clocks in $tz read $timestr";
+ } or do {
+ return "$requester: I'm unsure what the time is for $nick";
}
}
1;