@konplit-services/common 1.2.4 → 1.2.6
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.
|
@@ -15,6 +15,7 @@ export declare const getStartAndEndDate: (date: string | Date) => {
|
|
|
15
15
|
startOfDate: Date;
|
|
16
16
|
endOfDate: Date;
|
|
17
17
|
};
|
|
18
|
+
export declare const isTodayOrFuture: (dateInput: string | Date) => boolean;
|
|
18
19
|
export declare const convertDateToUTCRangeString: (startDateTime: string, endDateTime: string) => {
|
|
19
20
|
startUTC: string;
|
|
20
21
|
endUTC: string;
|
|
@@ -24,7 +25,7 @@ export declare const convertDateToUTCRange: (startDateTime: string, endDateTime:
|
|
|
24
25
|
endUTC: Date;
|
|
25
26
|
};
|
|
26
27
|
export declare const convertDateToUTCString: (startTime: string) => string;
|
|
27
|
-
export declare const convertDateToUTC: (startTime: string) => Date;
|
|
28
|
+
export declare const convertDateToUTC: (startTime: string | Date) => Date;
|
|
28
29
|
type PlanInterval = keyof typeof PLAN_INTERVAL;
|
|
29
30
|
export declare const getDuration: (duration: PlanInterval) => number;
|
|
30
31
|
export declare const getFutureDateFromPlan: (startDate: Date, duration: PlanInterval) => Date;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.canRefundFromSettlementLedgerByDay = exports.calculateDelay = exports.getFutureDateFromPlan = exports.getDuration = exports.convertDateToUTC = exports.convertDateToUTCString = exports.convertDateToUTCRange = exports.convertDateToUTCRangeString = exports.getStartAndEndDate = exports.getCurrentDayRange = exports.getPreviousDayRange = exports.convertToDate = exports.formatDateTime = exports.interswitchRefundDateFormat = exports.formatDate = void 0;
|
|
6
|
+
exports.canRefundFromSettlementLedgerByDay = exports.calculateDelay = exports.getFutureDateFromPlan = exports.getDuration = exports.convertDateToUTC = exports.convertDateToUTCString = exports.convertDateToUTCRange = exports.convertDateToUTCRangeString = exports.isTodayOrFuture = exports.getStartAndEndDate = exports.getCurrentDayRange = exports.getPreviousDayRange = exports.convertToDate = exports.formatDateTime = exports.interswitchRefundDateFormat = exports.formatDate = void 0;
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
8
|
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
9
9
|
// Extend dayjs with the UTC plugin
|
|
@@ -54,6 +54,15 @@ const getStartAndEndDate = (date) => {
|
|
|
54
54
|
return { startOfDate, endOfDate };
|
|
55
55
|
};
|
|
56
56
|
exports.getStartAndEndDate = getStartAndEndDate;
|
|
57
|
+
const isTodayOrFuture = (dateInput) => {
|
|
58
|
+
const input = dayjs_1.default.utc(dateInput);
|
|
59
|
+
if (!input.isValid())
|
|
60
|
+
return false;
|
|
61
|
+
const today = dayjs_1.default.utc().startOf('day');
|
|
62
|
+
const inputDay = input.startOf('day');
|
|
63
|
+
return inputDay.isSame(today) || inputDay.isAfter(today);
|
|
64
|
+
};
|
|
65
|
+
exports.isTodayOrFuture = isTodayOrFuture;
|
|
57
66
|
const convertDateToUTCRangeString = (startDateTime, endDateTime) => {
|
|
58
67
|
// Get the start of the previous day in UTC (00:00:00)
|
|
59
68
|
const startTime = (0, dayjs_1.default)(`${startDateTime}`, "YYYY-MM-DD HH:mm");
|