Time.time: simply channel-handling code for getting formats

This commit is contained in:
GLolol 2015-01-01 00:00:25 -05:00
parent a1d949c861
commit cc2780b78a

View File

@ -159,7 +159,7 @@ class Time(callbacks.Plugin):
TIME.time)]) TIME.time)])
@internationalizeDocstring @internationalizeDocstring
def time(self, irc, msg, args, channel, format, seconds): def time(self, irc, msg, args, format, seconds):
"""[<format>] [<seconds since epoch>] """[<format>] [<seconds since epoch>]
Returns the current time in <format> format, or, if <format> is not Returns the current time in <format> format, or, if <format> is not
@ -167,10 +167,7 @@ class Time(callbacks.Plugin):
<seconds since epoch> time is given, the current time is used. <seconds since epoch> time is given, the current time is used.
""" """
if not format: if not format:
if channel: format = self.registryValue('format', msg.args[0])
format = self.registryValue('format', channel)
else:
format = self.registryValue('format')
if tzlocal: if tzlocal:
irc.reply(datetime.fromtimestamp(seconds, tzlocal()).strftime(format)) irc.reply(datetime.fromtimestamp(seconds, tzlocal()).strftime(format))
else: else:
@ -178,8 +175,7 @@ class Time(callbacks.Plugin):
# including at least up to 2.7.5 and 3.2.3. Install dateutil if you # including at least up to 2.7.5 and 3.2.3. Install dateutil if you
# can't upgrade Python. # can't upgrade Python.
irc.reply(time.strftime(format, time.localtime(seconds))) irc.reply(time.strftime(format, time.localtime(seconds)))
time = wrap(time, [optional('channel'), optional('nonInt'), time = wrap(time, [optional('nonInt'), additional('float', TIME.time)])
additional('float', TIME.time)])
@internationalizeDocstring @internationalizeDocstring
def elapsed(self, irc, msg, args, seconds): def elapsed(self, irc, msg, args, seconds):