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.
|
Thanks for the fix. Could you update the existing |
The test passes "UTC" to Format but calculated the expected value with time.Local, so it failed on hosts outside UTC (as requested by @LinkinStars).
|
Done — the existing |
1 similar comment
|
Done — the existing |
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.