aboutsummaryrefslogtreecommitdiffstats
path: root/examples/tools/agenda.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tools/agenda.py')
-rwxr-xr-xexamples/tools/agenda.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/tools/agenda.py b/examples/tools/agenda.py
index 44bc34b..6c5bfca 100755
--- a/examples/tools/agenda.py
+++ b/examples/tools/agenda.py
@@ -77,6 +77,7 @@ def when(line):
def agenda(d, start, days):
# ponytail: naive local times, so a recurring event in a zone other than
# ours drifts by an hour across DST; multi-day events show on day one only.
+ # The weekday is printed because the model gets it wrong from a date.
lo = dt.datetime.fromisoformat(start)
hi = lo + dt.timedelta(days=days)
evs = []
@@ -106,7 +107,7 @@ def agenda(d, start, days):
occ = [first] if lo <= first < hi else []
summary = e.get("SUMMARY", "SUMMARY:(no title)").split(":", 1)[1]
summary = summary.replace("\\,", ",").replace("\\;", ";").replace("\\n", " ")
- out += [(t, f"{t:%Y-%m-%d} {'all day' if allday else f'{t:%H:%M}'} {summary}")
+ out += [(t, f"{t:%A %Y-%m-%d} {'all day' if allday else f'{t:%H:%M}'} {summary}")
for t in occ]
return [line for _, line in sorted(out)]
@@ -140,11 +141,11 @@ def test():
with open(os.path.join(d, "cal", name), "w", newline="") as f:
f.write(text)
assert agenda(d, "2026-09-01", 30) == [
- "2026-09-01 18:00 Gym", "2026-09-16 19:00 Gym moved",
- "2026-09-22 18:00 Gym", "2026-09-29 18:00 Gym"], agenda(d, "2026-09-01", 30)
- assert agenda(d, "2026-03-10", 5) == ["2026-03-12 all day Birthday"]
+ "Tuesday 2026-09-01 18:00 Gym", "Wednesday 2026-09-16 19:00 Gym moved",
+ "Tuesday 2026-09-22 18:00 Gym", "Tuesday 2026-09-29 18:00 Gym"], agenda(d, "2026-09-01", 30)
+ assert agenda(d, "2026-03-10", 5) == ["Thursday 2026-03-12 all day Birthday"]
assert agenda(d, "2026-10-01", 1) == [
- "2026-10-01 10:00 Dentist, checkup", "2026-10-01 18:00 Call"] # 16Z = 18 local
+ "Thursday 2026-10-01 10:00 Dentist, checkup", "Thursday 2026-10-01 18:00 Call"] # 16Z = 18 local
assert agenda(d, "2026-10-02", 1) == []
print("ok")