import re from datetime import datetime, timezone, timedelta def to_timestamp(dt_str, tz_str): dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S') pattern = re.compile(r'^UTC([+-]*\s*\d+):(\d{2})$') match = pattern.match(tz_str) tz_hours = match.group(1) tz_minutes = match.group(2) tz = timezone(timedelta(hours= int(tz_hours), minutes= int(tz_minutes))) tz_dt = dt.replace(tzinfo= tz) timestamp = tz_dt.timestamp() return timestamp
Sign in to make a reply
明天过后.