unixtolocal() converts to local timezone

This commit is contained in:
iou1name 2019-11-02 18:22:06 -04:00
parent d46fe77dca
commit cc148145d3

View File

@ -7,6 +7,7 @@ import datetime
from twisted.internet import defer
from module import commands
import tools.time
def setup(bot):
@ -75,5 +76,6 @@ def idleTimeWulf(result, bot):
def unixtolocal(bot, trigger):
"""Converts the given timestamp from unix time to local time."""
unix = int(trigger.group(2))
dt = datetime.datetime.utcfromtimestamp(unix).strftime('%Y-%m-%d %H:%M:%S')
bot.msg(dt)
dt = datetime.datetime.utcfromtimestamp(unix)
dt = dt.replace(tzinfo=datetime.timezone.utc)
bot.msg(dt.astimezone(tz=None).strftime('%Y-%m-%d %H:%M:%S'))