mirror of
https://github.com/Kunsi/scheduled-plugin-pretalx-broadcast-tools.git
synced 2024-11-25 03:21: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"
|
raw_schedule["conference"]["start"][:10], "%Y-%m-%d"
|
||||||
)
|
)
|
||||||
event_tz = pytz.timezone(raw_schedule["conference"]["time_zone_name"])
|
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 day in raw_schedule["conference"]["days"]:
|
||||||
for room in day["rooms"].values():
|
for room in day["rooms"].values():
|
||||||
for talk in room:
|
for talk in room:
|
||||||
start = datetime.strptime(
|
start = event_tz.localize(datetime.strptime(
|
||||||
talk["date"][:19], "%Y-%m-%dT%H:%M:%S"
|
talk["date"][:19], "%Y-%m-%dT%H:%M:%S"
|
||||||
).replace(tzinfo=event_tz)
|
))
|
||||||
d_h, d_m = talk["duration"].split(":")
|
d_h, d_m = talk["duration"].split(":")
|
||||||
end = start + timedelta(hours=int(d_h), minutes=int(d_m))
|
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["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"]
|
talk["locale"] = talk["language"]
|
||||||
|
|
||||||
track = None
|
track = None
|
||||||
|
|
Loading…
Reference in a new issue