Skip to content

Conversation

@DylanDevelops
Copy link
Owner

Pull Request Checklist

  • I have read and followed the contribution guidelines.
  • My pull request targets the main branch of tmpo.
  • I have tested these changes locally on my machine.

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

  • All database writes and updates involving timestamps (start_time, end_time, etc.) in time_entries and milestones are now explicitly converted to UTC before being saved. This affects creation, manual entry, updates, and milestone completion. [1] [2] [3] [4] [5] [6] [7]
  • On database initialization, a new settings table 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

  • New helper functions in global_config.go (getDisplayTimezone, toDisplayTime) allow times to be displayed in the user's configured timezone, falling back to local time if not set.
  • All time and date formatting functions (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

  • All logic for calculating time ranges in commands (log.go and stats.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.

DylanDevelops and others added 3 commits January 11, 2026 16:25
All time-related database fields are now stored in UTC, and a migration infrastructure has been introduced to convert existing timestamps to UTC. Time formatting functions now display times in the user's configured timezone. This ensures consistency across time zones and prepares the codebase for future database migrations.
Refactored database migration infrastructure from db.go to a new migrations.go file for better separation of concerns and maintainability. No functional changes were made; all migration-related functions and constants were relocated.
@DylanDevelops DylanDevelops changed the title Ravel/timezone sorting caused by timezone switches fix: Timestamps becoming messed up when switching timezones Jan 12, 2026
@DylanDevelops DylanDevelops merged commit 7bfe021 into main Jan 12, 2026
6 checks passed
@DylanDevelops DylanDevelops deleted the ravel/timezone-sorting-caused-by-timezone-switches branch January 12, 2026 01:06
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.

Incorrect Time Entry Sorting Due to Local Timezone Storage

2 participants