summaryrefslogtreecommitdiffstats
path: root/examples/tools
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tools')
-rwxr-xr-xexamples/tools/agenda.py11
-rw-r--r--examples/tools/calendar.toml2
2 files changed, 7 insertions, 6 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")
diff --git a/examples/tools/calendar.toml b/examples/tools/calendar.toml
index 75e4898..50b578c 100644
--- a/examples/tools/calendar.toml
+++ b/examples/tools/calendar.toml
@@ -8,4 +8,4 @@ description = "First day, YYYY-MM-DD. Empty for today."
[params.days]
type = "integer"
-description = "How many days, 1 for a single day. Empty for 1."
+description = "How many days, 1 for a single day, 30 or more for the next event. Empty for 1."