fix: Timestamps becoming messed up when switching timezones #66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
mainbranch of tmpo.Closes #62
Description
This pull request introduces a comprehensive migration to ensure all timestamps in the database are stored in UTC, improving consistency and reliability across time zone boundaries. It also adds support for user-configurable display time zones, ensuring that times are shown in the user's preferred format while remaining consistent in storage. The most important changes are grouped below:
Database Timestamp Standardization and Migration
start_time,end_time, etc.) intime_entriesandmilestonesare now explicitly converted to UTC before being saved. This affects creation, manual entry, updates, and milestone completion. [1] [2] [3] [4] [5] [6] [7]settingstable is created to track migration status and other metadata. The system runs a migration that converts all existing timestamps in relevant tables to UTC, with transactional safety and migration tracking. [1] [2]User Display Timezone Support
global_config.go(getDisplayTimezone,toDisplayTime) allow times to be displayed in the user's configured timezone, falling back to local time if not set.FormatTime,FormatTimePadded,FormatDate,FormatDateDashed,FormatDateLong,FormatDateTimeLong) now convert UTC times to the user's display timezone before formatting. [1] [2] [3] [4]Command Logic Consistency
log.goandstats.go) now consistently uses UTC, ensuring that queries and reports are accurate regardless of the server or client location. [1] [2] [3] [4]These changes collectively ensure that all stored timestamps are in UTC for consistency, while users see times in their preferred timezone, and pave the way for future database migrations.