Repository navigation
Conversation
day.Format takes an IANA time zone name, loads it and then throws the result away: the returned string was always produced in the server local zone. Every caller passes the zone explicitly -- the email/HTML templates via the timeFormat helpers, and schema/user_schema.go even hardcodes "UTC" for the suspended-until notice -- so dates were shown shifted whenever the container zone differed from the configured one. Apply the loaded location with time.Time.In, and keep the previous local behaviour when the zone is empty or unknown so that a bad value cannot silently shift an instant.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #
Proposed Changes
pkg/day.Formatnow applies thetzargument it already loaded withtime.Time.In; before,time.LoadLocation(tz)was called and its result dropped, so every rendered date was the server's local zone.TestFormatTimezone(UTC / Tokyo / New York / Kolkata / Los Angeles) plus a fallback test.Additional Info
Reproducer:
Format(1700000000, "YYYY-MM-DD HH:mm", "Asia/Tokyo")returned2023-11-14 22:13instead of
2023-11-15 07:13. This is the helper behind thetranslatorTimeFormatemail/UItemplates and behind the "suspended until" text that passes
"UTC"explicitly(
internal/schema/user_schema.go:202). No new dependency;go mod tidyandgolangci-lint v2.6.2(make lint) are clean.