def to_timestamp(dt_str, tz_str): dt=datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S') tz=re.split(r'''[UTC:00]''', tz_str) if tz[3]=='-': tz=-int(tz[4]) elif tz[3] =='+': tz = int(tz[4]) else: tz=int(tz[3]) tzutc = timezone(timedelta(hours=tz)) dt=dt.replace(tzinfo=tzutc) dt=dt.timestamp() return dt
Sign in to make a reply
bai渡者
def to_timestamp(dt_str, tz_str): dt=datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S') tz=re.split(r'''[UTC:00]''', tz_str) if tz[3]=='-': tz=-int(tz[4]) elif tz[3] =='+': tz = int(tz[4]) else: tz=int(tz[3]) tzutc = timezone(timedelta(hours=tz)) dt=dt.replace(tzinfo=tzutc) dt=dt.timestamp() return dt