diff options
-rw-r--r-- | data/rbot/plugins/time.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/data/rbot/plugins/time.rb b/data/rbot/plugins/time.rb index 5a1a579c..c89cf195 100644 --- a/data/rbot/plugins/time.rb +++ b/data/rbot/plugins/time.rb @@ -130,7 +130,13 @@ class TimePlugin < Plugin begin time = begin - Time.parse str + if zone = @registry[m.sourcenick] + on_timezone(zone) { + Time.parse str + } + else + Time.parse str + end rescue ArgumentError => e # Handle 28/9/1978, which is a valid date representation at least in Italy if e.message == 'argument out of range' @@ -158,6 +164,13 @@ class TimePlugin < Plugin :w => time >= now ? _("is") : _("was") } end + + def on_timezone(to_zone) + original_zone = ENV["TZ"] + ENV["TZ"] = to_zone + return yield + ENV["TZ"] = original_zone + end end class ::Time |