@wandzai/utils 1.0.47-ab-pre-release-11-t-2 → 1.0.47-ab-pre-release-11-t-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/schedule.d.ts +3 -7
- package/src/schedule.js +10 -24
- package/src/schedule.js.map +1 -1
package/package.json
CHANGED
package/src/schedule.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as dayjs from 'dayjs';
|
|
2
2
|
export { dayjs };
|
|
3
|
-
export declare const nowInUTC: () => dayjs.Dayjs;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const formatDate: (originalDate: string, format: string) => string;
|
|
7
|
-
export declare const compareWithTimezone: (date: string, timezone: string) => boolean;
|
|
8
|
-
export declare const dateWithOffset: (timezone: string, date?: string) => dayjs.Dayjs;
|
|
3
|
+
export declare const nowInUTC: (asDate?: boolean) => Date | dayjs.Dayjs;
|
|
4
|
+
export declare const isInPast: (date: Date) => boolean;
|
|
5
|
+
export declare const formatUTCDateWithTimezone: (date: Date, timezone: string, format: string) => string;
|
|
9
6
|
export declare const getTimezoneOffsetInHours: (region: string) => number;
|
|
10
|
-
export declare const convertToDateTimeString: (date: Date) => string;
|
package/src/schedule.js
CHANGED
|
@@ -1,41 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getTimezoneOffsetInHours = exports.formatUTCDateWithTimezone = exports.isInPast = exports.nowInUTC = exports.dayjs = void 0;
|
|
4
4
|
const dayjs = require("dayjs");
|
|
5
5
|
exports.dayjs = dayjs;
|
|
6
6
|
const utc = require("dayjs/plugin/utc");
|
|
7
7
|
const timezone = require("dayjs/plugin/timezone");
|
|
8
8
|
dayjs.extend(utc);
|
|
9
9
|
dayjs.extend(timezone);
|
|
10
|
-
const nowInUTC = () => dayjs().utc();
|
|
10
|
+
const nowInUTC = (asDate = true) => asDate ? dayjs().utc().toDate() : dayjs().utc();
|
|
11
11
|
exports.nowInUTC = nowInUTC;
|
|
12
|
-
const
|
|
13
|
-
exports.
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const isInPast = (date) => dayjs.utc(date).isBefore((0, exports.nowInUTC)());
|
|
13
|
+
exports.isInPast = isInPast;
|
|
14
|
+
const formatUTCDateWithTimezone = (date, timezone, format) => {
|
|
15
|
+
return dayjs
|
|
16
|
+
.utc(date)
|
|
17
|
+
.tz(timezone)
|
|
18
|
+
.format(format);
|
|
17
19
|
};
|
|
18
|
-
exports.
|
|
19
|
-
const formatDate = (originalDate, format) => {
|
|
20
|
-
return dayjs(originalDate).format(format);
|
|
21
|
-
};
|
|
22
|
-
exports.formatDate = formatDate;
|
|
23
|
-
const compareWithTimezone = (date, timezone) => {
|
|
24
|
-
return dayjs.tz(date, timezone).isBefore(dayjs().tz(timezone));
|
|
25
|
-
};
|
|
26
|
-
exports.compareWithTimezone = compareWithTimezone;
|
|
27
|
-
const dateWithOffset = (timezone, date) => {
|
|
28
|
-
return date
|
|
29
|
-
? dayjs.tz(date, timezone)
|
|
30
|
-
: dayjs().tz(timezone);
|
|
31
|
-
};
|
|
32
|
-
exports.dateWithOffset = dateWithOffset;
|
|
20
|
+
exports.formatUTCDateWithTimezone = formatUTCDateWithTimezone;
|
|
33
21
|
const getTimezoneOffsetInHours = (region) => {
|
|
34
22
|
const nowInTimezone = dayjs().tz(region);
|
|
35
23
|
const offsetInHours = nowInTimezone.utcOffset() / 60;
|
|
36
24
|
return parseFloat(offsetInHours.toFixed(1));
|
|
37
25
|
};
|
|
38
26
|
exports.getTimezoneOffsetInHours = getTimezoneOffsetInHours;
|
|
39
|
-
const convertToDateTimeString = (date) => date.toISOString().replace(/Z$/, '');
|
|
40
|
-
exports.convertToDateTimeString = convertToDateTimeString;
|
|
41
27
|
//# sourceMappingURL=schedule.js.map
|
package/src/schedule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../../../libs/utils/src/schedule.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAMtB,sBAAK;AALd,wCAAwC;AACxC,kDAAkD;AAElD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAClB,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAGhB,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"schedule.js","sourceRoot":"","sources":["../../../../libs/utils/src/schedule.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAMtB,sBAAK;AALd,wCAAwC;AACxC,kDAAkD;AAElD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAClB,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAGhB,MAAM,QAAQ,GAAG,CAAC,SAAkB,IAAI,EAAsB,EAAE,CACrE,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC;AADrC,QAAA,QAAQ,YAC6B;AAE3C,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAA,gBAAQ,GAAE,CAAC,CAAC;AAAzE,QAAA,QAAQ,YAAiE;AAE/E,MAAM,yBAAyB,GAAG,CAAC,IAAU,EAAE,QAAgB,EAAE,MAAc,EAAU,EAAE;IAChG,OAAO,KAAK;SACT,GAAG,CAAC,IAAI,CAAC;SACT,EAAE,CAAC,QAAQ,CAAC;SACZ,MAAM,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC,CAAC;AALW,QAAA,yBAAyB,6BAKpC;AAEK,MAAM,wBAAwB,GAAG,CAAC,MAAc,EAAU,EAAE;IAEjE,MAAM,aAAa,GAAG,KAAK,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAGzC,MAAM,aAAa,GAAG,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC;IAGrD,OAAO,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC;AATW,QAAA,wBAAwB,4BASnC"}
|