The calculation of default timeZoneOffsets currently returns + when it should be - and vice-versa. This is because .getTimezoneOffset() returns a positive value for negative timezones and vice-versa.
Changing:
const timeZoneOffset = getTimeZoneOffset(date.getTimezoneOffset() / 60);
to:
const timeZoneOffset = getTimeZoneOffset(-(date.getTimezoneOffset()) / 60);
accounts for this reversal.
This corrects three scenarios:
IF eventTime is not provided
AND eventTimeZoneOffset is not provided
THEN eventTime gets timeZone calculcated and appended with the wrong polarity
AND eventTimeZoneOffset gets calculated with the wrong polarity
objectEvent
// .setEventTime("2022-09-28T10:11:49Z")
// .setEventTimeZoneOffset("+08:00")
// In my time zone (-07:00) yields:
// "eventTimeZoneOffset": "+07:00",
// "eventTime": "2022-10-10T15:14:11.154+07:00",
IF eventTime is not provided
AND eventTimeZoneOffset is provided
THEN eventTime gets the timeZone calculated and appended with the wrong polarity
objectEvent
// .setEventTime("2022-09-28T10:11:49Z")
.setEventTimeZoneOffset("+08:00")
// In my time zone (-07:00) yields:
// "eventTimeZoneOffset": "+08:00",
// "eventTime": "2022-10-10T15:17:53.852+07:00",
IF eventTime is provided with "Z" suffix
AND eventTimeZoneOffset is not provided
THEN eventTimeZoneOffset is calculated with the wrong polarity
objectEvent
.setEventTime("2022-09-28T10:11:49Z")
// .setEventTimeZoneOffset("+08:00")
// In my time zone (-07:00) yields:
// "eventTimeZoneOffset": "+07:00",
// "eventTime": "2022-09-28T10:11:49Z",
The calculation of default timeZoneOffsets currently returns
+
when it should be-
and vice-versa. This is because .getTimezoneOffset() returns a positive value for negative timezones and vice-versa.Changing:
const timeZoneOffset = getTimeZoneOffset(date.getTimezoneOffset() / 60);
to:const timeZoneOffset = getTimeZoneOffset(-(date.getTimezoneOffset()) / 60);
accounts for this reversal.This corrects three scenarios:
AND eventTimeZoneOffset gets calculated with the wrong polarity
THEN eventTime gets the timeZone calculated and appended with the wrong polarity
THEN eventTimeZoneOffset is calculated with the wrong polarity