Skip to content

Convert time.Time to UTC before formatting timestamp parameter - #12

Open
vlehto wants to merge 2 commits into
krotscheck:mainfrom
vlehto:vlehto-convert-datetime-to-utc-before-formatting
Open

Convert time.Time to UTC before formatting timestamp parameter#12
vlehto wants to merge 2 commits into
krotscheck:mainfrom
vlehto:vlehto-convert-datetime-to-utc-before-formatting

Conversation

@vlehto

@vlehto vlehto commented May 22, 2026

Copy link
Copy Markdown

Summary

  • ConvertNamedValue in dialect.go now calls .UTC() on the incoming time.Time value before formatting it as a timestamp string
  • The formatted string has no timezone suffix, so MySQL and Aurora PostgreSQL (which default to UTC for naked datetime values) would silently misinterpret timestamps in any other timezone without this conversion
  • Tests added to dialect_test.go covering a non-UTC input (Europe/Helsinki) and a UTC input

Test plan

  • go test ./... -run Test_Dialect passes — non-UTC time is shifted to UTC in the formatted string, UTC time is unchanged

vlehto and others added 2 commits May 8, 2026 09:49
Convert incoming datetime value to UTC before formatting. Formatted timestamp does not use timezone, both MySQL and Aurora PostgreSQL default to UTC with naked datetime values.
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