Compare commits

...

2 Commits

Author SHA1 Message Date
Luca 756177089d Fix duration parsing
continuous-integration/drone/push Build is passing Details
2022-09-12 00:32:58 +02:00
Luca be97c32d03 Update schedule version, add new room names and s/CTF/Cyberspace/
continuous-integration/drone/push Build is failing Details
2022-09-12 00:21:19 +02:00
2 changed files with 17 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# fairydust.reisen website # fairydust.reisen website
Schedule version: `Hadar` Schedule version: `Intercrus`
## New pages/posts ## New pages/posts

View File

@ -7,15 +7,25 @@ from urllib.request import urlopen
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
GRANULARITY = 30 GRANULARITY = 30
ROOM_SEQUENCE = ('Sondermaschinenbau', 'Smart City Schmiede', 'Sofaecke', 'CTF') ROOM_SEQUENCE = ('Sondermaschinenbau', 'Smart City Schmiede', 'Sofaecke', 'Außenbereich', 'Rennstrecke', 'Cyberspace')
SCHEDULE_URL = 'https://cfp.fairydust.reisen/iger-2022/schedule/export/schedule.json' SCHEDULE_URL = 'https://cfp.fairydust.reisen/iger-2022/schedule/export/schedule.json'
TIMEZONE = 'Europe/Berlin' TIMEZONE = 'Europe/Berlin'
def parse_duration(s, num_parts): def parse_duration(s):
duration = 0 duration = 0
for t in s.split(':', maxsplit=num_parts-1): components = s.split(':')
if len(components) == 3:
duration += int(components[0])
duration *= 24
components = components[1:]
if len(components) == 2:
duration += int(components[0])
duration *= 60 duration *= 60
duration += int(t) duration += int(components[1])
else:
raise RuntimeError(f'invalid duration format: {s}')
return duration return duration
@ -54,14 +64,14 @@ def main():
event['start_date'] = date event['start_date'] = date
date += timedelta(seconds=parse_duration(event['duration'], 2)*60) date += timedelta(seconds=parse_duration(event['duration'])*60)
if end_date is None or date > end_date: if end_date is None or date > end_date:
end_date = date end_date = date
event['end_date'] = date event['end_date'] = date
timeline = [] timeline = []
timeslot = parse_duration(conference['timeslot_duration'], 2) timeslot = parse_duration(conference['timeslot_duration'])
for offset in range(0, int((end_date-start_date).total_seconds()), GRANULARITY*60): for offset in range(0, int((end_date-start_date).total_seconds()), GRANULARITY*60):
date = start_date + timedelta(seconds=offset) date = start_date + timedelta(seconds=offset)
timeline.append({'date': date.strftime('%Y-%m-%d'), 'start': offset//(timeslot*60)+1, 'time': date.strftime('%H:%M')}) timeline.append({'date': date.strftime('%Y-%m-%d'), 'start': offset//(timeslot*60)+1, 'time': date.strftime('%H:%M')})