mirror of
https://git.bolliret.ch/pcs/pcs-website
synced 2026-01-18 13:21:37 +01:00
57 lines
No EOL
1.8 KiB
Python
57 lines
No EOL
1.8 KiB
Python
from datetime import datetime, date, timezone
|
|
import locale
|
|
import sys
|
|
from calendarstuff import get_events
|
|
|
|
|
|
def fetch_upcoming_events(ics_url):
|
|
|
|
events = get_events(ics_url, 'de_DE.UTF-8')
|
|
|
|
for event in events:
|
|
|
|
start = event.get('dtstart').dt
|
|
out_summary = event.get('summary')
|
|
location = event.get('location', 'No location specified')
|
|
|
|
out_startdate = start.strftime("%a. %-d. %B %Y")
|
|
|
|
# Format output based on whether it's an all-day event
|
|
if isinstance(start, date) and not isinstance(start, datetime):
|
|
out_starttime = " "
|
|
else:
|
|
out_starttime = start.strftime('%-H:%M')
|
|
|
|
if location != 'No location specified':
|
|
out_location = location
|
|
else:
|
|
out_location = " "
|
|
|
|
print(f"* <div>{out_summary}</div> ")
|
|
print(f" * <div>{out_startdate}</div> ")
|
|
print(f" * <div>{out_starttime}</div> ")
|
|
print(f" * <div>{out_location}</div> ")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
ics_url = sys.argv[1]
|
|
|
|
# ics_url = "https://backoffice.pc-stammertal.ch/remote.php/dav/public-calendars/RqLX5wj25aY6cpnP?export"
|
|
|
|
print("_model: page")
|
|
print("---")
|
|
print("title: Termine")
|
|
print("---")
|
|
print("body:")
|
|
print("")
|
|
# print("<center><a href=\"https://backoffice.pc-stammertal.ch/remote.php/dav/public-calendars/RqLX5wj25aY6cpnP?export\">Kalender Abonnieren</a></center>")
|
|
# print("")
|
|
# print("<center><a href=\"https://backoffice.pc-stammertal.ch/remote.php/dav/public-calendars/RqLX5wj25aY6cpnP?export\"><img src=\"/images/calendar.png\" alt=\"Link als QR code\"></a></center>")
|
|
# print("")
|
|
fetch_upcoming_events(ics_url)
|
|
print("")
|
|
print("---")
|
|
print("_template: page.html")
|
|
print("")
|
|
print("") |