add timezone support to over.text.Output
This commit is contained in:
parent
a08c85a4f3
commit
6b518e8ddc
1 changed files with 3 additions and 2 deletions
|
@ -11,6 +11,7 @@ import struct
|
|||
import sys
|
||||
import time
|
||||
import termios
|
||||
import tzlocal
|
||||
|
||||
# --------------------------------------------------
|
||||
|
||||
|
@ -322,7 +323,7 @@ class Output:
|
|||
<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.format = format
|
||||
self.colors = colors and stream.isatty()
|
||||
|
@ -340,7 +341,7 @@ class Output:
|
|||
colors = colors or self.colors
|
||||
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("<n>", self.name)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue