def to_timestamp(dt_str, tz_str):
std=datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S')
retz=re.compile(r'^UTC([\+\-]?[\d]+)(\:00$)')
tz_utc = timezone(timedelta(hours=int(retz.match(tz_str).group(1))))
dt = std.replace(tzinfo=tz_utc)
return dt.timestamp()
Sign in to make a reply
Mx
def to_timestamp(dt_str, tz_str):
std=datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S')
retz=re.compile(r'^UTC([\+\-]?[\d]+)(\:00$)')
tz_utc = timezone(timedelta(hours=int(retz.match(tz_str).group(1))))
dt = std.replace(tzinfo=tz_utc)
return dt.timestamp()