feat: add utcOffset in webhook payload (#12709)

* add utcOffset in webhook

* add utcOffset in webhook

* fix type

* fix type

* fix function error

* fix: UTCOffset DST

* getUTCOffsetByTimezone support date param

* add startTime in `getUTCOffsetByTimezone` func

---------

Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
Ethan ChenandKeith Williams authored and GitHub committed 2024-01-11 14:35:02 +00:00
1 parent 5950c5a756
commit 026f22fbaf
2 files changed
+51 -3

No files matched your search

+12
View File
@@ -226,3 +226,15 @@ export const isInDST = (date: Dayjs) => {
return timeZoneWithDST(timeZone) && date.utcOffset() === getUTCOffsetInDST(timeZone);
};
/**
* Get UTC offset of given time zone
* @param timeZone Time Zone Name (Ex. America/Mazatlan)
* @param date
* @returns
*/
export function getUTCOffsetByTimezone(timeZone: string, date?: string | Date | Dayjs) {
if (!timeZone) return null;
return dayjs(date).tz(timeZone).utcOffset();
}