ddr-scores/utils.py

13 lines
356 B
Python
Raw Normal View History

2024-05-04 10:29:20 +00:00
from datetime import datetime
import pytz
JST = pytz.timezone("Asia/Tokyo")
CST = pytz.timezone("America/Chicago")
def to_jst_timestamp(s: str, format_str="%Y-%m-%d %H:%M:%S"):
if type(s) is not str: return None
naive_dt = datetime.strptime(s, format_str)
jst_dt = JST.localize(naive_dt)
cst_dt = jst_dt.astimezone(CST)
return cst_dt