aboutsummaryrefslogtreecommitdiff
path: root/Plugin
diff options
context:
space:
mode:
authorDavid Phillips <david@sighup.nz>2019-04-05 20:44:12 +1300
committerDavid Phillips <david@sighup.nz>2019-04-05 20:47:25 +1300
commit2a9a151c64d07578728fdc42c84b9a9ea10974f6 (patch)
treec995d43e78505da70d632d86fdb704c8d7764ec3 /Plugin
parenta2390fa651ed4d51d885b0f306ffceb8b3752a0c (diff)
downloadidalius-2a9a151c64d07578728fdc42c84b9a9ea10974f6.tar.xz
Timzone: Allow arbitrary timezone specification
Diffstat (limited to 'Plugin')
-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;