diff options
author | Raine Virta <rane@kapsi.fi> | 2009-02-04 23:36:22 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-02-07 13:39:37 +0100 |
commit | 169fc6ff43667987ce57804653e4b5b73aaf2d08 (patch) | |
tree | d838ac6584ea87c313b82b565699093e56d997a2 /data/rbot/plugins | |
parent | 2b81b5d6ec06fbf9e32300eeb9caece8c26d33b7 (diff) |
remind plugin: added possibility to reference times that are the next day as hh:mm
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/remind.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/data/rbot/plugins/remind.rb b/data/rbot/plugins/remind.rb index 0d6e9ecc..e3f248ef 100644 --- a/data/rbot/plugins/remind.rb +++ b/data/rbot/plugins/remind.rb @@ -58,18 +58,19 @@ class RemindPlugin < Plugin else raise "invalid time string" end - when (/^(\d+):(\d+):(\d+)$/) + when (/^(\d+):(\d+)(?:\:(\d+))?$/) hour = $1.to_i min = $2.to_i sec = $3.to_i now = Time.now later = Time.mktime(now.year, now.month, now.day, hour, min, sec) - return later - now - when (/^(\d+):(\d+)$/) - hour = $1.to_i - min = $2.to_i - now = Time.now - later = Time.mktime(now.year, now.month, now.day, hour, min, now.sec) + + # if the given hour is earlier than current hour, given timestr + # must have been meant to be in the future + if hour < now.hour || hour <= now.hour && min < now.min + later += 60*60*24 + end + return later - now when (/^(\d+):(\d+)(am|pm)$/) hour = $1.to_i |