mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Merge pull request #914 from nyuszika7h/time-workaround-python-bug
Time.time: Work around a Python bug
This commit is contained in:
commit
175a646500
@ -58,6 +58,11 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
parse = None
|
parse = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
from dateutil.tz import tzlocal
|
||||||
|
except ImportError:
|
||||||
|
tzlocal = None
|
||||||
|
|
||||||
class Time(callbacks.Plugin):
|
class Time(callbacks.Plugin):
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def seconds(self, irc, msg, args):
|
def seconds(self, irc, msg, args):
|
||||||
@ -160,7 +165,13 @@ class Time(callbacks.Plugin):
|
|||||||
format = self.registryValue('format', channel)
|
format = self.registryValue('format', channel)
|
||||||
else:
|
else:
|
||||||
format = self.registryValue('format')
|
format = self.registryValue('format')
|
||||||
irc.reply(time.strftime(format, time.localtime(seconds)))
|
if tzlocal:
|
||||||
|
irc.reply(datetime.fromtimestamp(seconds, tzlocal()).strftime(format))
|
||||||
|
else:
|
||||||
|
# NOTE: This has erroneous behavior on some older Python versions,
|
||||||
|
# including at least up to 2.7.5 and 3.2.3. Install dateutil if you
|
||||||
|
# can't upgrade Python.
|
||||||
|
irc.reply(time.strftime(format, time.localtime(seconds)))
|
||||||
time = wrap(time, [optional('channel'), optional('nonInt'),
|
time = wrap(time, [optional('channel'), optional('nonInt'),
|
||||||
additional('float', TIME.time)])
|
additional('float', TIME.time)])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user