mirror of
https://github.com/Kunsi/scheduled-plugin-pretalx-broadcast-tools.git
synced 2024-11-24 19:11:05 +00:00
service: use pytz.localize() instead of datetime.replace()
This commit is contained in:
parent
f2c341183d
commit
ef96cfb88c
1 changed files with 4 additions and 5 deletions
9
service
9
service
|
@ -125,20 +125,19 @@ def main():
|
|||
raw_schedule["conference"]["start"][:10], "%Y-%m-%d"
|
||||
)
|
||||
event_tz = pytz.timezone(raw_schedule["conference"]["time_zone_name"])
|
||||
utc_offset = datetime.now(event_tz).utcoffset().total_seconds()
|
||||
|
||||
for day in raw_schedule["conference"]["days"]:
|
||||
for room in day["rooms"].values():
|
||||
for talk in room:
|
||||
start = datetime.strptime(
|
||||
start = event_tz.localize(datetime.strptime(
|
||||
talk["date"][:19], "%Y-%m-%dT%H:%M:%S"
|
||||
).replace(tzinfo=event_tz)
|
||||
))
|
||||
d_h, d_m = talk["duration"].split(":")
|
||||
end = start + timedelta(hours=int(d_h), minutes=int(d_m))
|
||||
|
||||
talk["start_ts"] = int(timegm(start.timetuple()) - utc_offset)
|
||||
talk["start_ts"] = int(timegm(start.timetuple()) - start.utcoffset().total_seconds())
|
||||
talk["start_str"] = talk["start"]
|
||||
talk["end_ts"] = int(timegm(end.timetuple()) - utc_offset)
|
||||
talk["end_ts"] = int(timegm(end.timetuple()) - end.utcoffset().total_seconds())
|
||||
talk["locale"] = talk["language"]
|
||||
|
||||
track = None
|
||||
|
|
Loading…
Reference in a new issue