Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static ensureTimezoneDstCalculated(timezone) {
if (!(timezone in _timezoneOffsetAndDst)) {
// If a location has DST, the offset from GMT at January 1 and June 1 will certainly
// be different. The greater of the two is the DST offset. For our check, we
// don't care when DST is (March-October in the northern hemisphere, October-March
// in the southern hemisphere). We only care about the offset during DST.
const januaryDate = new DateTime(
new Date().getFullYear(),
1,
1,
0,
0,
0,
0,
zone(timezone)
);
const julyDate = new DateTime(
new Date().getFullYear(),
6,
1,
0,
0,
0,
if (!(timezone in _timezoneOffsetAndDst)) {
// If a location has DST, the offset from GMT at January 1 and June 1 will certainly
// be different. The greater of the two is the DST offset. For our check, we
// don't care when DST is (March-October in the northern hemisphere, October-March
// in the southern hemisphere). We only care about the offset during DST.
const januaryDate = new DateTime(
new Date().getFullYear(),
1,
1,
0,
0,
0,
0,
zone(timezone)
);
const julyDate = new DateTime(
new Date().getFullYear(),
6,
1,
0,
0,
0,
0,
zone(timezone)
);
_timezoneOffsetAndDst[timezone] = new TimezoneOffsetAndDst(
Math.min(januaryDate.offset(), julyDate.offset()),
januaryDate.offset() !== julyDate.offset()
);
}
}