blob: 70754f3a1d8f33320840c9b65003267a03d9d640 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/usr/bin/env python3
import os
import re
import sys
from datetime import datetime
# DTSTART:20251130
for slug in sys.argv[1:]:
ics_path = os.path.join("events", slug, "ics")
ics_content = open(ics_path, "rb").read().decode("utf-8", errors="ignore")
date_path = os.path.join("events", slug, "date")
if os.path.exists(date_path):
continue
date = re.search(r"DTSTART:(\d+)", ics_content)
assert date is not None
date = date[1]
dt = datetime.strptime(date, "%Y%m%d")
with open(date_path, "w") as f:
f.write(dt.isoformat())
|