@drivekyte/date-utils
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -62,4 +62,15 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
// TODO: remove this workaround for the timezone issue: https://git.drivekyte.com/kytecoredevelopers/date-utils/-/issues/7 | ||
const utcFix = (option, dayjsClass) => { | ||
// eslint-disable-next-line no-param-reassign | ||
dayjsClass.prototype.valueOf = function () { | ||
const addedOffset = !this.$utils().u(this.$offset) | ||
? this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset()) | ||
: 0; | ||
return this.$d.valueOf() - addedOffset * 60 * 1000; | ||
}; | ||
}; | ||
dayjs.extend(dayjsUTC); | ||
dayjs.extend(dayjsTimezone); | ||
dayjs.extend(utcFix); | ||
const getDateInServiceAreaTz = (date, timezone) => dayjs(date).tz(timezone, true).toDate().getTime(); | ||
@@ -66,0 +77,0 @@ const getDateInTz = (date, timezone) => { |
@@ -66,4 +66,15 @@ 'use strict'; | ||
// TODO: remove this workaround for the timezone issue: https://git.drivekyte.com/kytecoredevelopers/date-utils/-/issues/7 | ||
const utcFix = (option, dayjsClass) => { | ||
// eslint-disable-next-line no-param-reassign | ||
dayjsClass.prototype.valueOf = function () { | ||
const addedOffset = !this.$utils().u(this.$offset) | ||
? this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset()) | ||
: 0; | ||
return this.$d.valueOf() - addedOffset * 60 * 1000; | ||
}; | ||
}; | ||
dayjs.extend(dayjsUTC); | ||
dayjs.extend(dayjsTimezone); | ||
dayjs.extend(utcFix); | ||
const getDateInServiceAreaTz = (date, timezone) => dayjs(date).tz(timezone, true).toDate().getTime(); | ||
@@ -70,0 +81,0 @@ const getDateInTz = (date, timezone) => { |
@@ -10,4 +10,15 @@ "use strict"; | ||
const timezone_1 = __importDefault(require("dayjs/plugin/timezone")); | ||
// TODO: remove this workaround for the timezone issue: https://git.drivekyte.com/kytecoredevelopers/date-utils/-/issues/7 | ||
const utcFix = (option, dayjsClass) => { | ||
// eslint-disable-next-line no-param-reassign | ||
dayjsClass.prototype.valueOf = function () { | ||
const addedOffset = !this.$utils().u(this.$offset) | ||
? this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset()) | ||
: 0; | ||
return this.$d.valueOf() - addedOffset * 60 * 1000; | ||
}; | ||
}; | ||
dayjs_1.default.extend(utc_1.default); | ||
dayjs_1.default.extend(timezone_1.default); | ||
dayjs_1.default.extend(utcFix); | ||
const getDateInServiceAreaTz = (date, timezone) => (0, dayjs_1.default)(date).tz(timezone, true).toDate().getTime(); | ||
@@ -14,0 +25,0 @@ const getDateInTz = (date, timezone) => { |
{ | ||
"name": "@drivekyte/date-utils", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141144
563