Discuss / Python / 打卡

打卡

Topic source

°Destiny

#1 Created at ... [Delete] [Delete and Lock User]
def to_timestamp(dt_str, tz_str):
    cday = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
    m=re.match(r'UTC(.\d+):(\d+)',tz_str)
    h=int(m.group(1))
    tz_utc = timezone(timedelta(hours=h))
    dt = cday.replace(tzinfo=tz_utc)
    return dt.timestamp()

  • 1

Reply