def to_timestamp(dt_str, tz_str): dt = datetime.strptime(dt_str, "%Y-%m-%d %H:%M:%S") tz = re.findall(r"C(.+):", tz_str)[0] tz_utc = timezone(timedelta(hours=int(tz))) timestamp = dt.replace(tzinfo=tz_utc).timestamp() return timestamp
Sign in to make a reply
做一个优秀的社会人
def to_timestamp(dt_str, tz_str): dt = datetime.strptime(dt_str, "%Y-%m-%d %H:%M:%S") tz = re.findall(r"C(.+):", tz_str)[0] tz_utc = timezone(timedelta(hours=int(tz))) timestamp = dt.replace(tzinfo=tz_utc).timestamp() return timestamp