You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
analytics-utils: localTime() offset hour is wrong in negative half-hour timezones #524
localTime() in analytics-utils returns the wrong offset hour in negative half-hour timezones.
Steps to reproduce
process.env.TZ='Pacific/Marquesas'// UTC-09:30localTime().slice(-6)// "-10:30"process.env.TZ='America/St_Johns'// UTC-03:30 (UTC-02:30 in summer)localTime().slice(-6)// "-04:30" (or "-03:30" in summer)
Expected -09:30 and -03:30 (or -02:30).
Cause
The hour is built with pad(tzo / 60), and pad does Math.abs(Math.floor(n)). For UTC-09:30, Math.floor(-9.5) is -10, so the hour is off by one in every negative half-hour zone. Positive and whole-hour zones are fine.
Activity