@wandzai/utils 1.0.39-dates-diff-1 → 1.0.39
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/date.d.ts +1 -2
- package/src/date.js +1 -17
- package/src/date.js.map +1 -1
package/package.json
CHANGED
package/src/date.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DaysRanges
|
|
1
|
+
import { DaysRanges } from "@wandzai/wandz-interfaces";
|
|
2
2
|
export declare const formatDateYearMonthDay: (date: string | Date) => string;
|
|
3
3
|
export declare const calcDatesRange: (range: DaysRanges) => {
|
|
4
4
|
startDate: string;
|
|
5
5
|
endDate: string;
|
|
6
6
|
};
|
|
7
|
-
export declare const getTimeDifference: (date: Date, timeUnit: TimeUnits) => number;
|
package/src/date.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const wandz_interfaces_1 = require("@wandzai/wandz-interfaces");
|
|
3
|
+
exports.calcDatesRange = exports.formatDateYearMonthDay = void 0;
|
|
5
4
|
const formatDateYearMonthDay = (date) => new Date(date).toLocaleDateString('en-CA', { year: 'numeric', month: '2-digit', day: '2-digit' });
|
|
6
5
|
exports.formatDateYearMonthDay = formatDateYearMonthDay;
|
|
7
6
|
const calcDatesRange = (range) => {
|
|
@@ -14,19 +13,4 @@ const calcDatesRange = (range) => {
|
|
|
14
13
|
};
|
|
15
14
|
};
|
|
16
15
|
exports.calcDatesRange = calcDatesRange;
|
|
17
|
-
const getTimeDifference = (date, timeUnit) => {
|
|
18
|
-
const now = new Date();
|
|
19
|
-
const timeDifference = now.getTime() - date.getTime();
|
|
20
|
-
switch (timeUnit) {
|
|
21
|
-
case wandz_interfaces_1.TimeUnits.Hours:
|
|
22
|
-
return timeDifference / (1000 * 60 * 60);
|
|
23
|
-
case wandz_interfaces_1.TimeUnits.Minutes:
|
|
24
|
-
return timeDifference / (1000 * 60);
|
|
25
|
-
case wandz_interfaces_1.TimeUnits.Seconds:
|
|
26
|
-
return timeDifference / 1000;
|
|
27
|
-
default:
|
|
28
|
-
return timeDifference;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
exports.getTimeDifference = getTimeDifference;
|
|
32
16
|
//# sourceMappingURL=date.js.map
|
package/src/date.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../libs/utils/src/date.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../../libs/utils/src/date.ts"],"names":[],"mappings":";;;AAEO,MAAM,sBAAsB,GAAG,CAAC,IAAmB,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;AAApJ,QAAA,sBAAsB,0BAA8H;AAE1J,MAAM,cAAc,GAAG,CAC1B,KAAiB,EACnB,EAAE;IACA,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;IACzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC;IAE3C,OAAO;QACH,SAAS,EAAE,IAAA,8BAAsB,EAAC,SAAS,CAAC;QAC5C,OAAO,EAAE,IAAA,8BAAsB,EAAC,KAAK,CAAC;KACzC,CAAC;AACN,CAAC,CAAA;AAXY,QAAA,cAAc,kBAW1B"}
|