13 lines
356 B
Python
13 lines
356 B
Python
|
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
|