Time zone handling
Build and Push CodeReview / build (push) Waiting to run
Details
Build and Push CodeReview / build (push) Waiting to run
Details
This commit is contained in:
parent
3ce3767938
commit
dfefdfe432
|
|
@ -13,9 +13,17 @@ def get_now_iso():
|
||||||
|
|
||||||
def beijing_time(*args):
|
def beijing_time(*args):
|
||||||
"""
|
"""
|
||||||
用于 logging.Formatter.converter 的转换函数
|
用于 logging.Formatter.converter 的转换函数。
|
||||||
|
支持 (timestamp) 或 (formatter, timestamp) 调用形式。
|
||||||
"""
|
"""
|
||||||
if args:
|
if len(args) == 2:
|
||||||
# args[0] 是 timestamp
|
# 被作为 bound method 调用: (self, timestamp)
|
||||||
return datetime.fromtimestamp(args[0], CHINA_TZ).timetuple()
|
ts = args[1]
|
||||||
return get_now().timetuple()
|
elif len(args) == 1:
|
||||||
|
# 被作为普通函数调用: (timestamp)
|
||||||
|
ts = args[0]
|
||||||
|
else:
|
||||||
|
# 无参数调用(不常见,但作为兜底)
|
||||||
|
ts = datetime.now().timestamp()
|
||||||
|
|
||||||
|
return datetime.fromtimestamp(ts, CHINA_TZ).timetuple()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue