diff options
| author | diogo464 <[email protected]> | 2025-07-21 15:02:48 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-07-21 15:02:48 +0100 |
| commit | 8c8dabd0ed20679a2dad43a5c239f9fcfe1c1ad7 (patch) | |
| tree | 55abbcfbbff19efa3aaf6cf36540ac7651c54973 /extract-date | |
init
Diffstat (limited to 'extract-date')
| -rwxr-xr-x | extract-date | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/extract-date b/extract-date new file mode 100755 index 000000000..727b77b1e --- /dev/null +++ b/extract-date | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #!/usr/bin/env python3 | ||
| 2 | import os | ||
| 3 | import re | ||
| 4 | import sys | ||
| 5 | |||
| 6 | from datetime import datetime | ||
| 7 | |||
| 8 | # DTSTART:20251130 | ||
| 9 | |||
| 10 | for slug in sys.argv[1:]: | ||
| 11 | ics_path = os.path.join("events", slug, "ics") | ||
| 12 | ics_content = open(ics_path, "rb").read().decode("utf-8", errors="ignore") | ||
| 13 | |||
| 14 | date_path = os.path.join("events", slug, "date") | ||
| 15 | if os.path.exists(date_path): | ||
| 16 | continue | ||
| 17 | |||
| 18 | date = re.search(r"DTSTART:(\d+)", ics_content) | ||
| 19 | assert date is not None | ||
| 20 | date = date[1] | ||
| 21 | |||
| 22 | dt = datetime.strptime(date, "%Y%m%d") | ||
| 23 | with open(date_path, "w") as f: | ||
| 24 | f.write(date_path) | ||
| 25 | |||
