add timezone support to over.text.Output

This commit is contained in:
Martinez 2016-10-20 17:03:17 +02:00
parent a08c85a4f3
commit 6b518e8ddc

View file

@ -11,6 +11,7 @@ import struct
import sys import sys
import time import time
import termios import termios
import tzlocal
# -------------------------------------------------- # --------------------------------------------------
@ -322,7 +323,7 @@ class Output:
<i> - indentation start marker <i> - indentation start marker
""" """
def __init__(self, name, format="[%Y-%m-%d %H:%M:%S] <@> -- <n>, <i><t>", colors=True, end=".\n", indent=True, stream=sys.stderr): def __init__(self, name, format="[%Y-%m-%d %H:%M:%S %Z] <@> -- <n>, <i><t>", colors=True, end=".\n", indent=True, stream=sys.stderr):
self.name = name self.name = name
self.format = format self.format = format
self.colors = colors and stream.isatty() self.colors = colors and stream.isatty()
@ -340,7 +341,7 @@ class Output:
colors = colors or self.colors colors = colors or self.colors
end = end or self.end end = end or self.end
output = datetime.datetime.now().strftime(format) output = datetime.datetime.now(tzlocal.get_localzone()).strftime(format)
output = output.replace("<@>", tag) output = output.replace("<@>", tag)
output = output.replace("<n>", self.name) output = output.replace("<n>", self.name)