fix: sync timezone fix

This commit is contained in:
Krispire Admin
2026-06-09 11:56:22 +05:30
parent 6c61e97bba
commit 0d189739d6
+8 -1
View File
@@ -85,9 +85,16 @@ const fallbackTZ = "Asia/Kolkata"
// resolveTZ returns the user's IANA timezone name + loaded location, falling // resolveTZ returns the user's IANA timezone name + loaded location, falling
// back to Asia/Kolkata (then UTC) so the day boundary is always defined. // back to Asia/Kolkata (then UTC) so the day boundary is always defined.
//
// The users.timezone column defaults to 'UTC' (migration 0028), so a bare
// "UTC" means the browser never reported a real zone — i.e. we don't actually
// know the user's local time. Per product intent we treat that as unknown and
// fall back to India time, rather than literally bucketing their day at UTC
// midnight (which mismatches the browser-local calendar on the client). A
// genuine UTC user re-reports their real zone on next load.
func (s *SadhnaService) resolveTZ(ctx context.Context, userID string) (string, *time.Location) { func (s *SadhnaService) resolveTZ(ctx context.Context, userID string) (string, *time.Location) {
tz, _ := s.logs.UserTimezone(ctx, userID) tz, _ := s.logs.UserTimezone(ctx, userID)
if tz == "" { if tz == "" || tz == "UTC" {
tz = fallbackTZ tz = fallbackTZ
} }
loc, err := time.LoadLocation(tz) loc, err := time.LoadLocation(tz)