def to_timestamp(dt_str, tz_str):
temp_time = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
if re.match(r'^UTC\+([0-9]|0[0-9]|1[0-2]):00$', tz_str):
temp_timezone = timezone(timedelta(hours=int(re.match(r'^UTC\+([0-9]|0[0-9]|1[0-2]):00$', tz_str).group(1))))
elif re.match(r'^UTC\-([0-9]|0[0-9]|1[0-2]):00$', tz_str):
temp_timezone = timezone(timedelta(hours=-int(re.match(r'^UTC\-([0-9]|0[0-9]|1[0-2]):00$', tz_str).group(1))))
dt = temp_time.replace(tzinfo=temp_timezone)
dt_timestamp = dt.timestamp()
return dt_timestamp
评论列表
文章目录