交作业
Topic sourcedef to_timestamp(dt_str, tz_str): dt = datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S') tz_m=re.match(r'^UTC(.\d+):(\d+)$',tz_str) tz=int(tz_m[1]) in_dt=dt.replace(tzinfo=timezone(timedelta(hours=tz)))
#utc_dt=in_dt.astimezone(timezone(timedelta(hours=0)))
#return utc_dt.timestamp()
return in_dt.timestamp()
- 1
Alvin天枭
def to_timestamp(dt_str, tz_str): dt = datetime.strptime(dt_str,'%Y-%m-%d %H:%M:%S') tz_m=re.match(r'^UTC(.\d+):(\d+)$',tz_str) tz=int(tz_m[1]) in_dt=dt.replace(tzinfo=timezone(timedelta(hours=tz))) utc_dt=in_dt.astimezone(timezone(timedelta(hours=0))) return utc_dt.timestamp()