Fix a bug

This commit is contained in:
xtaodada 2022-04-29 23:54:07 +08:00
parent 7921e259e2
commit c895b0be13
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -5,7 +5,10 @@ date_format = "%Y-%m-%dT%H:%M:%SZ"
def strf_time(data: str) -> str:
# data = "2021-07-17T09:14:05Z"
ts = datetime.strptime(data, date_format)
if data:
ts = datetime.strptime(data, date_format)
else:
return "未知"
# UTC+8
ts = ts + timedelta(hours=8)
return ts.strftime("%Y/%m/%d %H:%M:%S")