Steps to reproduce:
import timezoneMock from 'timezone-mock';
timezoneMock.register('UTC');
new Date().getTimezoneOffset(); // returns -0
this causes issues when using jest because toEqual uses Object.is under the hood, so this assertion fails:
timezoneMock.register('UTC');
const offset = new Date().getTimezoneOffset();
expect(offset).toEqual(0); // fails because Object.is(-0, 0) return false
and instead an ugly workaround is required:
expect(offset === 0).toBe(true);
I'd expect getTimezoneOffset to return 0 for UTC instead of -0
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset#negative_values_and_positive_values
Steps to reproduce:
this causes issues when using jest because
toEqualusesObject.isunder the hood, so this assertion fails:and instead an ugly workaround is required:
I'd expect
getTimezoneOffsetto return0for UTC instead of-0https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset#negative_values_and_positive_values