]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - data/rbot/plugins/remind.rb
grouphug: log errors
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / remind.rb
index 0d6e9eccb88c8f1f9c4fa4a0bfd68bc7cd884f67..e3f248ef6ef91529bd97e48f5e7a266b26faf50b 100644 (file)
@@ -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