diff --git a/plugins/Time.py b/plugins/Time.py index 3b864f7a0..f7b018a28 100644 --- a/plugins/Time.py +++ b/plugins/Time.py @@ -40,9 +40,13 @@ __contributors__ = {} import supybot.plugins as plugins import time +TIME = time + +import dateutil.parser import supybot.conf as conf import supybot.utils as utils +from supybot.commands import wrap import supybot.privmsgs as privmsgs import supybot.registry as registry import supybot.callbacks as callbacks @@ -63,6 +67,21 @@ conf.registerChannelValue(conf.supybot.plugins.Time, 'format', time module to see what formats are accepted. If you set this variable to the empty string, the timestamp will not be shown.""")) +def parse(s): + todo = [] + s = s.replace('noon', '12:00') + s = s.replace('midnight', '00:00') + if 'tomorrow' in s: + todo.append(lambda i: i + 86400) + s = s.replace('tomorrow', '') + if 'next week' in s: + todo.append(lambda i: i + 86400*7) + s = s.replace('next week', '') + i = int(time.mktime(dateutil.parser.parse(s, fuzzy=True).timetuple())) + for f in todo: + i = f(i) + return i + class Time(callbacks.Privmsg): def seconds(self, irc, msg, args): """[y] [w] [d] [h] [m] [s] @@ -98,21 +117,35 @@ class Time(callbacks.Privmsg): seconds += i irc.reply(str(seconds)) - def _at(self, irc, msg, args): + def at(self, irc, msg, args): """