I'm using ideas from this implementation to get time zone offset, but because of standard defined inversion logic for offsets the code looks like this:
const [, sign, hour, minute] = matchData;
let result = parseInt(hour) * 60;
if (sign === '+') result *= -1;
if (minute) result += parseInt(minute);
and for the Asia/Kolkata
with offset +5:30
it returns -270
, which is weird. I'd expect it to be -1 * (5*60 + 30) = -330
, or even more intuitive not inverted value 5*60 + 30 = 330
, but not -270
.
Is this the error or is it consistent with the standard?