diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-18 15:29:35 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-18 15:29:35 +0200 |
| commit | 48fa63ff5d0e12edf86db7f01def635aa0aaa9fb (patch) | |
| tree | 28bdd13bf12cf51464b01975ee4e9eef08596f85 /lib | |
| parent | e81d0c6f7e975b1b98f1adf84299ba921093d100 (diff) | |
| download | conky-theme-udt-48fa63ff5d0e12edf86db7f01def635aa0aaa9fb.tar.gz conky-theme-udt-48fa63ff5d0e12edf86db7f01def635aa0aaa9fb.zip | |
fix(calendar): mark events past this week on the month grid
The sampler asked khal for 8 days only, so the grid never coloured an
event later in the month. Sample through the month's end instead, and
cut the event table back to the coming week with calendar_upcoming().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/data.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/data.lua b/lib/data.lua index 1b4c64f..818bbf1 100644 --- a/lib/data.lua +++ b/lib/data.lua @@ -131,6 +131,21 @@ function M.calendar_month_days(events, year, month) return out end +-- The events falling within `days` days of `today` ({ y, m, d }), today +-- included. The cache spans the rest of the month so the grid can mark it, +-- while the event table under the grid stays a week's view. +function M.calendar_upcoming(events, today, days) + local out = {} + if type(events) ~= 'table' or type(today) ~= 'table' then return out end + local t0 = os.time({ year = today[1], month = today[2], day = today[3], + hour = 12 }) + for _, e in ipairs(events) do + local t = os.time({ year = e.y, month = e.m, day = e.d, hour = 12 }) + if (t - t0) / 86400 < days then out[#out + 1] = e end + end + return out +end + -- Days in a month, and the weekday its 1st falls on. -- -- os.time/os.date rather than a leap-year rule: the C library already knows, |
