Skip to content

fix(examples): clip time spent today to local calendar bounds - #164

Open
TimeToBuildBob wants to merge 3 commits into
ActivityWatch:masterfrom
TimeToBuildBob:fix/today-local-day-clipping
Open

TimeToBuildBob wants to merge 3 commits into
ActivityWatch:masterfrom
TimeToBuildBob:fix/today-local-day-clipping

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Summary

  • Capture now once, derive both local calendar midnights independently, and convert each to UTC (23/25-hour DST days).
  • Sum nonnegative intersections of not-AFK events with midnight through captured now, without modifying events or changing bucket selection/output format.
  • Add executable-example regressions for midnight overlap, future tails, out-of-range/zero/negative durations, AFK exclusion, empty results and Stockholm spring/fall bounds.

Reproduction and validation

Fresh upstream master c88cf12 prints 2:00:00 for a 23:00–01:00 active event when queried at noon; only 1:00:00 belongs to today. New regressions before repair: 11 failed / 4 passed. After repair: all 15 pass; 74 targeted tests pass including profile/config/proxy coverage. Repository-wide make typecheck passes (31 files); Ruff lint/format and whitespace checks pass. The independent filing-time behavior probe now prints 1:00:00 on this branch.

This repository has no make test-fast target; explicit bounded pytest slices were used instead. Tests use synthetic events and a controlled clock, not live user history. Process-local TZ regressions require time.tzset and skip on Windows; Linux/macOS exercise them. No datastore overlap, deduplication, historical workday or interval-union policy changes.

Git-Session-Id: 350bcd90-c80d-427d-9595-03c4285ca081
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Updates time_spent_today.py to count only active time between local midnight and one captured now.

  • The daily total counts active time only within today's local bounds.

Reviews (1) · Last reviewed commit: "fix(examples): clip time spent today to ..." · Reviewed by Greptile

Git-Session-Id: 56060ebf-6713-5eee-b092-043118cee230
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Fixed the build setup failure in 4f2c298: Python 3.9 is unavailable on Ubuntu 26.04, which ubuntu-latest now selects. Pinned the Linux build to ubuntu-24.04; Python 3.9 and the native Windows/macOS jobs are unchanged.

Local verification: 137 offline tests passed (including all 15 local-day regressions), mypy passed for 31 source files, and the workflow YAML/matrix checks passed. The new CI run is queued, including Test on ubuntu-24.04; hosted success is not yet verified. The three most recent master Build runs passed, but predate this runner-image change.

Git-Session-Id: de442d75-d4a4-527d-b790-fac44a8340cc
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Fixed the Windows typecheck failure in ef1755a. The previous run passed Linux/macOS and Windows runtime tests, but Windows mypy rejected the nested fixture's direct time.tzset() access even though the tests skip on that platform. The fixture now captures the optional setter with getattr and uses it only after the existing skip guard; application behavior and CI checks are unchanged.

Verified locally: the exact Windows-target mypy error reproduced before the fix; afterward all 31 files pass mypy for Windows, Linux and macOS targets. All 137 offline tests pass on Linux, and removing time.tzset in an isolated test process produces the expected 15 skips. Scoped Ruff lint/format and whitespace checks pass. The pushed head is ef1755ad3b1973d886595b4d29e2540f047b7ada. Hosted CI now passes all seven checks, including the Windows/Linux/macOS Build matrix (run 41008395350). Maintainer review/merge and integrated-master replay remain separate gates.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant