localTime() in analytics-utils returns the wrong offset hour in negative half-hour timezones.
Steps to reproduce
process.env.TZ = 'Pacific/Marquesas' // UTC-09:30
localTime().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.
Version: analytics-utils 1.1.1 (master)
localTime()inanalytics-utilsreturns the wrong offset hour in negative half-hour timezones.Steps to reproduce
Expected
-09:30and-03:30(or-02:30).Cause
The hour is built with
pad(tzo / 60), andpaddoesMath.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.Version: analytics-utils 1.1.1 (master)