dayjs-tz-helper
Version:
46 lines (45 loc) • 2.62 kB
JavaScript
!function(e, s) {
"object" == typeof exports && "undefined" != typeof module ? s(exports, require("dayjs"), require("dayjs/plugin/utc"), require("dayjs/plugin/timezone"), require("@lazy-num/parse-number-string")) : "function" == typeof define && define.amd ? define([ "exports", "dayjs", "dayjs/plugin/utc", "dayjs/plugin/timezone", "@lazy-num/parse-number-string" ], s) : s((e = "undefined" != typeof globalThis ? globalThis : e || self).DayjsTzHelper = {}, e.dayjs, e.utc, e.timezone, e.parseNumberString);
}(this, (function(e, s, t, n, i) {
"use strict";
function _isUnsafeOffsetDateString(e) {
return /(?:\dZ|\+\d{2}:?\d{2})$/.test(e);
}
function _isUnsafeUTCDateString(e) {
return /(?:GMT|UTC)/.test(e);
}
function tzDayjsSafeParse(e, t) {
var n, a;
return null !== t && "object" == typeof t || (t = {
timezone: t
}), "number" == typeof e || i.isFloatString(e) ? (e = Number(e), "number" == typeof t.minValidTimestamp ? e = Math.max(e, t.minValidTimestamp) : t.minValidTimestamp && (e = Math.max(e, 0)),
e = (t.isUnixTimestampSeconds ? s.unix : s)(e)) : "string" == typeof e && (_isUnsafeOffsetDateString(e) ? e = s.utc(e) : "GMT" !== t.timezone || _isUnsafeUTCDateString(e) ? e = s(e) : e += " GMT"),
s.tz(null !== (n = e) && void 0 !== n ? n : void 0, null !== (a = t.timezone) && void 0 !== a ? a : void 0);
}
function secondsToMilliseconds(e) {
return 1000 * e;
}
function millisecondsToSeconds(e) {
return e / 1000;
}
s.extend(t), s.extend(n), Object.defineProperty(tzDayjsSafeParse, "__esModule", {
value: !0
}), Object.defineProperty(tzDayjsSafeParse, "tzDayjsSafeParse", {
value: tzDayjsSafeParse
}), Object.defineProperty(tzDayjsSafeParse, "default", {
value: tzDayjsSafeParse
}), Object.defineProperty(tzDayjsSafeParse, "_isUnsafeOffsetDateString", {
value: _isUnsafeOffsetDateString
}), Object.defineProperty(tzDayjsSafeParse, "_isUnsafeUTCDateString", {
value: _isUnsafeUTCDateString
}), Object.defineProperty(tzDayjsSafeParse, "secondsToMilliseconds", {
value: secondsToMilliseconds
}), Object.defineProperty(tzDayjsSafeParse, "millisecondsToSeconds", {
value: millisecondsToSeconds
}), e._isUnsafeOffsetDateString = _isUnsafeOffsetDateString, e._isUnsafeUTCDateString = _isUnsafeUTCDateString,
e.default = tzDayjsSafeParse, e.millisecondsToSeconds = millisecondsToSeconds, e.secondsToMilliseconds = secondsToMilliseconds,
e.tzDayjsSafeParse = tzDayjsSafeParse, Object.defineProperty(e, "__esModule", {
value: !0
});
}));
//# sourceMappingURL=index.umd.production.min.cjs.map