-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The problem
tmpo stores timestamps in the SQLite database using the local system time (including the timezone offset) via time.Now(). Because SQLite uses lexicographical string comparison for queries, changing the system timezone causes entries to be sorted and filtered incorrectly.
For example, an entry created at 19:00-05:00 is lexicographically "smaller" than 20:00+00:00, even though the first time is actually 4 hours later in absolute time. This leads to tmpo stats and tmpo log returning incorrect results (e.g., missing entries for "today") when the user travels or changes timezones.
Release version
0.4.1 (01-06-2026)
Operating system
Windows 11
Steps to reproduce the behavior
- Set your system timezone to
UTC-5(e.g., America/New_York). - Run
tmpo startto create an entry, wait a moment, thentmpo stop. - Change your system timezone to
UTC. - Run
tmpo stats --today. - Observe that the entry created in step 2 is missing from the statistics because the string comparison logic fails to account for the timezone offset difference.
Screenshots
No response
Additional context
Root Cause:
The CreateEntry function in internal/storage/db.go uses time.Now() which persists the local offset. SQLite's BETWEEN and ORDER BY clauses operate on these strings directly.
Proposed Solution:
Modify internal/storage/db.go to always store timestamps in UTC (using time.Now().UTC()). The UI layer should handle converting these UTC timestamps back to the user's local time for display purposes.