@wandzai/utils 1.0.47-ab-pre-release-11-t-3 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wandzai/utils",
3
- "version": "1.0.47-ab-pre-release-11-t-3",
3
+ "version": "1.0.47-ab-pre-release-11-t-4",
4
4
  "description": "Common used utilities library",
5
5
  "main": "src/index",
6
6
  "scripts": {
package/src/schedule.d.ts CHANGED
@@ -2,5 +2,5 @@ import * as dayjs from 'dayjs';
2
2
  export { dayjs };
3
3
  export declare const nowInUTC: (asDate?: boolean) => Date | dayjs.Dayjs;
4
4
  export declare const isInPast: (date: Date) => boolean;
5
- export declare const formatDate: (originalDate: Date, format: string) => string;
5
+ export declare const formatUTCDateWithTimezone: (date: Date, timezone: string, format: string) => string;
6
6
  export declare const getTimezoneOffsetInHours: (region: string) => number;
package/src/schedule.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTimezoneOffsetInHours = exports.formatDate = exports.isInPast = exports.nowInUTC = exports.dayjs = void 0;
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");
@@ -11,10 +11,13 @@ const nowInUTC = (asDate = true) => asDate ? dayjs().utc().toDate() : dayjs().ut
11
11
  exports.nowInUTC = nowInUTC;
12
12
  const isInPast = (date) => dayjs.utc(date).isBefore((0, exports.nowInUTC)());
13
13
  exports.isInPast = isInPast;
14
- const formatDate = (originalDate, format) => {
15
- return dayjs(originalDate).format(format);
14
+ const formatUTCDateWithTimezone = (date, timezone, format) => {
15
+ return dayjs
16
+ .utc(date)
17
+ .tz(timezone)
18
+ .format(format);
16
19
  };
17
- exports.formatDate = formatDate;
20
+ exports.formatUTCDateWithTimezone = formatUTCDateWithTimezone;
18
21
  const getTimezoneOffsetInHours = (region) => {
19
22
  const nowInTimezone = dayjs().tz(region);
20
23
  const offsetInHours = nowInTimezone.utcOffset() / 60;
@@ -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,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,UAAU,GAAG,CAAC,YAAkB,EAAE,MAAc,EAAU,EAAE;IACvE,OAAO,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;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,C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