@rocketlink/crm-model 1.0.126 → 1.0.128
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/dist/dtos/csv.request.dto.d.ts +0 -2
- package/dist/dtos/csv.request.dto.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/model/recurringSettingConfig.model.d.ts +6 -2
- package/dist/model/recurringSettingConfig.model.d.ts.map +1 -1
- package/dist/model/recurringSettingConfig.model.js +5 -0
- package/dist/model/transaction.model.d.ts +0 -3
- package/dist/model/transaction.model.d.ts.map +1 -1
- package/dist/model/transaction.model.js +1 -2
- package/dist/util/constants.d.ts +0 -2
- package/dist/util/constants.d.ts.map +1 -1
- package/dist/util/constants.js +1 -3
- package/dist/util/{dateUtil.d.ts → dateUtils.d.ts} +5 -18
- package/dist/util/dateUtils.d.ts.map +1 -0
- package/dist/util/{dateUtil.js → dateUtils.js} +2 -102
- package/package.json +1 -1
- package/src/dtos/csv.request.dto.ts +0 -2
- package/src/index.ts +2 -2
- package/src/model/recurringSettingConfig.model.ts +6 -2
- package/src/model/transaction.model.ts +1 -4
- package/src/util/constants.ts +1 -5
- package/src/util/dateUtils.ts +98 -0
- package/dist/util/countryUtil.d.ts +0 -2
- package/dist/util/countryUtil.d.ts.map +0 -1
- package/dist/util/countryUtil.js +0 -7
- package/dist/util/dateUtil.d.ts.map +0 -1
- package/src/util/countryUtil.ts +0 -3
- package/src/util/dateUtil.ts +0 -238
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.request.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/csv.request.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"csv.request.dto.d.ts","sourceRoot":"","sources":["../../src/dtos/csv.request.dto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './util/constants';
|
|
2
|
-
export * from './util/
|
|
3
|
-
export { isDateString, dateToString, stringToDate, getCurrentDateCompacted, FORMATS } from './util/
|
|
2
|
+
export * from './util/dateUtils';
|
|
3
|
+
export { isDateString, dateToString, stringToDate, getCurrentDateCompacted, FORMATS } from './util/dateUtils';
|
|
4
4
|
export * from './util/numberUtils';
|
|
5
5
|
export * from './dtos/common/base.request.dto';
|
|
6
6
|
export * from './dtos/common/paginated.request.dto';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3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ACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sCAAsC,CAAC;AACrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAG/C,cAAc,gDAAgD,CAAC;AAC/D,cAAc,qDAAqD,CAAC;AACpE,cAAc,kDAAkD,CAAC;AAGjE,cAAc,sDAAsD,CAAC;AACrE,cAAc,2DAA2D,CAAC;AAC1E,cAAc,wDAAwD,CAAC;AAGvE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0CAA0C,CAAC;AACzD,cAAc,iDAAiD,CAAC;AAChE,cAAc,8CAA8C,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,13 +17,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.FORMATS = exports.getCurrentDateCompacted = exports.stringToDate = exports.dateToString = exports.isDateString = void 0;
|
|
18
18
|
// Export constants
|
|
19
19
|
__exportStar(require("./util/constants"), exports);
|
|
20
|
-
__exportStar(require("./util/
|
|
21
|
-
var
|
|
22
|
-
Object.defineProperty(exports, "isDateString", { enumerable: true, get: function () { return
|
|
23
|
-
Object.defineProperty(exports, "dateToString", { enumerable: true, get: function () { return
|
|
24
|
-
Object.defineProperty(exports, "stringToDate", { enumerable: true, get: function () { return
|
|
25
|
-
Object.defineProperty(exports, "getCurrentDateCompacted", { enumerable: true, get: function () { return
|
|
26
|
-
Object.defineProperty(exports, "FORMATS", { enumerable: true, get: function () { return
|
|
20
|
+
__exportStar(require("./util/dateUtils"), exports);
|
|
21
|
+
var dateUtils_1 = require("./util/dateUtils");
|
|
22
|
+
Object.defineProperty(exports, "isDateString", { enumerable: true, get: function () { return dateUtils_1.isDateString; } });
|
|
23
|
+
Object.defineProperty(exports, "dateToString", { enumerable: true, get: function () { return dateUtils_1.dateToString; } });
|
|
24
|
+
Object.defineProperty(exports, "stringToDate", { enumerable: true, get: function () { return dateUtils_1.stringToDate; } });
|
|
25
|
+
Object.defineProperty(exports, "getCurrentDateCompacted", { enumerable: true, get: function () { return dateUtils_1.getCurrentDateCompacted; } });
|
|
26
|
+
Object.defineProperty(exports, "FORMATS", { enumerable: true, get: function () { return dateUtils_1.FORMATS; } });
|
|
27
27
|
__exportStar(require("./util/numberUtils"), exports);
|
|
28
28
|
// Export all DTOs
|
|
29
29
|
__exportStar(require("./dtos/common/base.request.dto"), exports);
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
export declare const INTERVAL_UNIT: {
|
|
2
|
+
readonly DAYS: "DAYS";
|
|
3
|
+
readonly MONTHS: "MONTHS";
|
|
4
|
+
};
|
|
5
|
+
export type INTERVAL_UNIT = (typeof INTERVAL_UNIT)[keyof typeof INTERVAL_UNIT];
|
|
2
6
|
export interface RecurringSettingConfig {
|
|
3
7
|
id?: number;
|
|
4
8
|
name?: string;
|
|
5
|
-
intervalUnit?:
|
|
9
|
+
intervalUnit?: INTERVAL_UNIT;
|
|
6
10
|
intervalPeriod?: number;
|
|
7
11
|
maxTriesAfterFailure?: number;
|
|
8
12
|
maxDelayPeriod?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recurringSettingConfig.model.d.ts","sourceRoot":"","sources":["../../src/model/recurringSettingConfig.model.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"recurringSettingConfig.model.d.ts","sourceRoot":"","sources":["../../src/model/recurringSettingConfig.model.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE/E,MAAM,WAAW,sBAAsB;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BANKS } from "./gateway.model";
|
|
2
|
-
import { Mid } from "./mid.model";
|
|
3
2
|
export declare const TRANSACTION_STATUS: {
|
|
4
3
|
PENDING_ASYNC: string;
|
|
5
4
|
SUCCESS: string;
|
|
@@ -17,7 +16,6 @@ export declare const PAYMENT_TYPE: {
|
|
|
17
16
|
SDD_SALE: string;
|
|
18
17
|
REFUND: string;
|
|
19
18
|
CHARGEBACK: string;
|
|
20
|
-
DEBIT: string;
|
|
21
19
|
};
|
|
22
20
|
export type PAYMENT_TYPE = (typeof PAYMENT_TYPE)[keyof typeof PAYMENT_TYPE];
|
|
23
21
|
export interface Transaction {
|
|
@@ -26,7 +24,6 @@ export interface Transaction {
|
|
|
26
24
|
amount?: string;
|
|
27
25
|
currency?: string;
|
|
28
26
|
midId?: number;
|
|
29
|
-
mid?: Mid;
|
|
30
27
|
orderId?: number;
|
|
31
28
|
internalPaymentType?: PAYMENT_TYPE;
|
|
32
29
|
internalTransactionType?: APP_TRANSACTION_TYPE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.model.d.ts","sourceRoot":"","sources":["../../src/model/transaction.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction.model.d.ts","sourceRoot":"","sources":["../../src/model/transaction.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,M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(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CURRENCIES = exports.SAFE_WHILE_LIMIT = exports.EVENTS = exports.SUBSCRIPTION_STATUS = exports.ORDER_STATUS_VALUES = exports.ORDER_STATUS = exports.TRANSACTION_TYPE_CODE = exports.TRANSACTION_TYPE_VALUES = exports.ALL = exports.TRANSACTION_TYPE = exports.OFFER_TYPE = exports.REGISTRATION_MODE = exports.CSV_ROW_STATUS = exports.CSV_STATUS = exports.CSV_TYPE_VALUES = exports.CSV_TYPES = exports.MIME_TYPES = exports.YES_NO = void 0;
|
|
4
4
|
exports.YES_NO = {
|
|
5
5
|
YES: "Y",
|
|
6
6
|
NO: "N",
|
|
@@ -85,5 +85,3 @@ exports.CURRENCIES = {
|
|
|
85
85
|
USD: "USD",
|
|
86
86
|
GBP: "GBP",
|
|
87
87
|
};
|
|
88
|
-
exports.MB_1 = 1 * 1024 * 1024;
|
|
89
|
-
exports.MAX_MB_STREAM_SIZE = exports.MB_1 * 5;
|
|
@@ -6,16 +6,10 @@ export declare const FORMATS: {
|
|
|
6
6
|
readonly COMPACT_DATETIME: "yyyyMMddHHmmss";
|
|
7
7
|
readonly COMPACT_DATE: "yyyyMMdd";
|
|
8
8
|
};
|
|
9
|
-
export declare
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type INTERVAL_UNIT = (typeof INTERVAL_UNIT)[keyof typeof INTERVAL_UNIT];
|
|
14
|
-
export declare function dateToString(date?: Date, formatString?: string): string;
|
|
15
|
-
export declare function dateToYYYYMMDD(date?: Date): string;
|
|
16
|
-
export declare function dateToTZ(date?: Date): string;
|
|
17
|
-
export declare function dateToMinutes(date?: Date): string;
|
|
18
|
-
export declare function dateToMinutesSeconds(date?: Date): string;
|
|
9
|
+
export declare function dateToString(date: Date, formatString?: string): string;
|
|
10
|
+
export declare function dateToYYYYMMDD(date: Date): string;
|
|
11
|
+
export declare function dateToTZ(date: Date): string;
|
|
12
|
+
export declare function dateToMinutes(date: Date): string;
|
|
19
13
|
export declare function getCurrentDateCompacted(): string;
|
|
20
14
|
export declare function isDateString(value: string): boolean;
|
|
21
15
|
export declare function stringToDate(value: string): Date;
|
|
@@ -28,11 +22,4 @@ export declare function addDaysToDate(date: Date, days: number): Date;
|
|
|
28
22
|
export declare function subtractDaysFromDate(date: Date, days: number): Date;
|
|
29
23
|
export declare function addDaysToDateString(value: string, days: number, formatString?: string): string;
|
|
30
24
|
export declare function subtractDaysFromDateString(value: string, days: number, formatString?: string): string;
|
|
31
|
-
|
|
32
|
-
export declare function addPeriodToDate(date: Date, period: number, unit: INTERVAL_UNIT): Date;
|
|
33
|
-
export type UiDateInput = Date | string;
|
|
34
|
-
export type FormatDateForUiOptions = {
|
|
35
|
-
includeSeconds?: boolean;
|
|
36
|
-
};
|
|
37
|
-
export declare function formatDateForUi(value: UiDateInput | null | undefined, options?: FormatDateForUiOptions): string;
|
|
38
|
-
//# sourceMappingURL=dateUtil.d.ts.map
|
|
25
|
+
//# sourceMappingURL=dateUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/util/dateUtils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;;;;;;;CAOV,CAAC;AAIX,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAKxF;AACD,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEjD;AACD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE3C;AACD,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEhD;AACD,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnD;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAShD;AAID,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAM/F;AACD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AACD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AACD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AACD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AAKD,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAK5D;AACD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAKnE;AACD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAIhH;AACD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAIvH"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FORMATS = void 0;
|
|
4
4
|
exports.dateToString = dateToString;
|
|
5
5
|
exports.dateToYYYYMMDD = dateToYYYYMMDD;
|
|
6
6
|
exports.dateToTZ = dateToTZ;
|
|
7
7
|
exports.dateToMinutes = dateToMinutes;
|
|
8
|
-
exports.dateToMinutesSeconds = dateToMinutesSeconds;
|
|
9
8
|
exports.getCurrentDateCompacted = getCurrentDateCompacted;
|
|
10
9
|
exports.isDateString = isDateString;
|
|
11
10
|
exports.stringToDate = stringToDate;
|
|
@@ -18,9 +17,6 @@ exports.addDaysToDate = addDaysToDate;
|
|
|
18
17
|
exports.subtractDaysFromDate = subtractDaysFromDate;
|
|
19
18
|
exports.addDaysToDateString = addDaysToDateString;
|
|
20
19
|
exports.subtractDaysFromDateString = subtractDaysFromDateString;
|
|
21
|
-
exports.addMonthsToDate = addMonthsToDate;
|
|
22
|
-
exports.addPeriodToDate = addPeriodToDate;
|
|
23
|
-
exports.formatDateForUi = formatDateForUi;
|
|
24
20
|
const date_fns_1 = require("date-fns");
|
|
25
21
|
exports.FORMATS = {
|
|
26
22
|
ISO_DATE: 'yyyy-MM-dd', // "2026-01-07"
|
|
@@ -30,16 +26,12 @@ exports.FORMATS = {
|
|
|
30
26
|
COMPACT_DATETIME: 'yyyyMMddHHmmss', // "20260107143000"
|
|
31
27
|
COMPACT_DATE: 'yyyyMMdd', // "20260107"
|
|
32
28
|
};
|
|
33
|
-
exports.INTERVAL_UNIT = {
|
|
34
|
-
DAYS: "DAYS",
|
|
35
|
-
MONTHS: "MONTHS",
|
|
36
|
-
};
|
|
37
29
|
// ============================================
|
|
38
30
|
// Date → String formatted conversions
|
|
39
31
|
// ============================================
|
|
40
32
|
function dateToString(date, formatString = exports.FORMATS.ISO_DATE) {
|
|
41
33
|
if (!date || !(0, date_fns_1.isValid)(date)) {
|
|
42
|
-
|
|
34
|
+
throw new Error('Invalid date: ' + date);
|
|
43
35
|
}
|
|
44
36
|
return (0, date_fns_1.format)(date, formatString);
|
|
45
37
|
}
|
|
@@ -52,9 +44,6 @@ function dateToTZ(date) {
|
|
|
52
44
|
function dateToMinutes(date) {
|
|
53
45
|
return dateToString(date, exports.FORMATS.ISO_DATE_TIME_MINUTES);
|
|
54
46
|
}
|
|
55
|
-
function dateToMinutesSeconds(date) {
|
|
56
|
-
return dateToString(date, exports.FORMATS.ISO_DATE_TIME_SECONDS);
|
|
57
|
-
}
|
|
58
47
|
function getCurrentDateCompacted() {
|
|
59
48
|
return dateToYYYYMMDD(new Date()); // "20260107143000"
|
|
60
49
|
}
|
|
@@ -123,92 +112,3 @@ function subtractDaysFromDateString(value, days, formatString = exports.FORMATS.
|
|
|
123
112
|
const newDate = (0, date_fns_1.subDays)(date, days);
|
|
124
113
|
return (0, date_fns_1.format)(newDate, formatString);
|
|
125
114
|
}
|
|
126
|
-
function addMonthsToDate(date, months) {
|
|
127
|
-
if (!date || !(0, date_fns_1.isValid)(date)) {
|
|
128
|
-
throw new Error('Invalid date: ' + date);
|
|
129
|
-
}
|
|
130
|
-
return (0, date_fns_1.addMonths)(date, months);
|
|
131
|
-
}
|
|
132
|
-
function addPeriodToDate(date, period, unit) {
|
|
133
|
-
if (!date || !(0, date_fns_1.isValid)(date)) {
|
|
134
|
-
throw new Error('Invalid date: ' + date);
|
|
135
|
-
}
|
|
136
|
-
if (unit === exports.INTERVAL_UNIT.MONTHS) {
|
|
137
|
-
date = addMonthsToDate(date, period);
|
|
138
|
-
}
|
|
139
|
-
else if (unit === exports.INTERVAL_UNIT.DAYS) {
|
|
140
|
-
date = addDaysToDate(date, period);
|
|
141
|
-
}
|
|
142
|
-
return date;
|
|
143
|
-
}
|
|
144
|
-
//"15 Jan 2024, 10:30:40" or "15 Jan 2024, 10:30" or just "15 Jan 2024".
|
|
145
|
-
const parseUiDate = (value) => {
|
|
146
|
-
if (value instanceof Date) {
|
|
147
|
-
const d = value;
|
|
148
|
-
if (Number.isNaN(d.getTime()))
|
|
149
|
-
return null;
|
|
150
|
-
const hasTime = d.getHours() !== 0 ||
|
|
151
|
-
d.getMinutes() !== 0 ||
|
|
152
|
-
d.getSeconds() !== 0 ||
|
|
153
|
-
d.getMilliseconds() !== 0;
|
|
154
|
-
return { date: d, hasTime };
|
|
155
|
-
}
|
|
156
|
-
const raw = String(value).trim();
|
|
157
|
-
if (!raw)
|
|
158
|
-
return null;
|
|
159
|
-
// Explicit "dd.MM.yyyy" (e.g. "31.07.2024") -> date-only
|
|
160
|
-
const dotDateMatch = raw.match(/^(\d{2})\.(\d{2})\.(\d{4})$/);
|
|
161
|
-
if (dotDateMatch) {
|
|
162
|
-
const [, dd, mm, yyyy] = dotDateMatch;
|
|
163
|
-
const d = new Date(Number(yyyy), Number(mm) - 1, Number(dd));
|
|
164
|
-
if (Number.isNaN(d.getTime()))
|
|
165
|
-
return null;
|
|
166
|
-
return { date: d, hasTime: false };
|
|
167
|
-
}
|
|
168
|
-
// Plain ISO date "YYYY-MM-DD" -> date-only
|
|
169
|
-
const isoDateOnlyMatch = raw.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
170
|
-
if (isoDateOnlyMatch) {
|
|
171
|
-
const [, yyyy, mm, dd] = isoDateOnlyMatch;
|
|
172
|
-
const d = new Date(Number(yyyy), Number(mm) - 1, Number(dd));
|
|
173
|
-
if (Number.isNaN(d.getTime()))
|
|
174
|
-
return null;
|
|
175
|
-
return { date: d, hasTime: false };
|
|
176
|
-
}
|
|
177
|
-
// Fallback to native parser for ISO timestamps and other formats.
|
|
178
|
-
const d = new Date(raw);
|
|
179
|
-
if (Number.isNaN(d.getTime()))
|
|
180
|
-
return null;
|
|
181
|
-
// If the original string clearly contained a time (has 'T' or an HH:MM),
|
|
182
|
-
// treat it as having a time component, otherwise fall back to midnight check.
|
|
183
|
-
const explicitTime = /T\d\d?:\d\d/.test(raw) || /\d{1,2}:\d{2}/.test(raw);
|
|
184
|
-
const hasTime = explicitTime ||
|
|
185
|
-
d.getHours() !== 0 ||
|
|
186
|
-
d.getMinutes() !== 0 ||
|
|
187
|
-
d.getSeconds() !== 0 ||
|
|
188
|
-
d.getMilliseconds() !== 0;
|
|
189
|
-
return { date: d, hasTime };
|
|
190
|
-
};
|
|
191
|
-
function formatDateForUi(value, options) {
|
|
192
|
-
if (!value) {
|
|
193
|
-
return '-';
|
|
194
|
-
}
|
|
195
|
-
const parsed = parseUiDate(value);
|
|
196
|
-
if (!parsed) {
|
|
197
|
-
return '-';
|
|
198
|
-
}
|
|
199
|
-
const { date, hasTime } = parsed;
|
|
200
|
-
const includeSeconds = options?.includeSeconds ?? false;
|
|
201
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
202
|
-
const monthShort = date.toLocaleString('en-US', { month: 'short' });
|
|
203
|
-
const year = date.getFullYear();
|
|
204
|
-
const base = `${day} ${monthShort} ${year}`;
|
|
205
|
-
if (!hasTime) {
|
|
206
|
-
return base;
|
|
207
|
-
}
|
|
208
|
-
const hours = String(date.getHours()).padStart(2, '0');
|
|
209
|
-
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
210
|
-
const time = includeSeconds
|
|
211
|
-
? `${hours}:${minutes}:${String(date.getSeconds()).padStart(2, '0')}`
|
|
212
|
-
: `${hours}:${minutes}`;
|
|
213
|
-
return `${base}, ${time}`;
|
|
214
|
-
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Export constants
|
|
2
2
|
export * from './util/constants';
|
|
3
|
-
export * from './util/
|
|
4
|
-
export { isDateString, dateToString, stringToDate, getCurrentDateCompacted, FORMATS } from './util/
|
|
3
|
+
export * from './util/dateUtils';
|
|
4
|
+
export { isDateString, dateToString, stringToDate, getCurrentDateCompacted, FORMATS } from './util/dateUtils';
|
|
5
5
|
export * from './util/numberUtils';
|
|
6
6
|
|
|
7
7
|
// Export all DTOs
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
export const INTERVAL_UNIT = {
|
|
2
|
+
DAYS: "DAYS",
|
|
3
|
+
MONTHS: "MONTHS",
|
|
4
|
+
} as const;
|
|
5
|
+
export type INTERVAL_UNIT = (typeof INTERVAL_UNIT)[keyof typeof INTERVAL_UNIT];
|
|
2
6
|
|
|
3
7
|
export interface RecurringSettingConfig {
|
|
4
8
|
id?: number;
|
|
5
9
|
name?: string;
|
|
6
|
-
intervalUnit?:
|
|
10
|
+
intervalUnit?: INTERVAL_UNIT;
|
|
7
11
|
intervalPeriod?: number;
|
|
8
12
|
maxTriesAfterFailure?: number;
|
|
9
13
|
maxDelayPeriod?: number;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BANKS } from "./gateway.model";
|
|
2
|
-
import { Mid } from "./mid.model";
|
|
3
2
|
|
|
4
3
|
export const TRANSACTION_STATUS = {
|
|
5
4
|
PENDING_ASYNC: "PENDING_ASYNC",
|
|
@@ -19,8 +18,7 @@ export type APP_TRANSACTION_TYPE = (typeof APP_TRANSACTION_TYPE)[keyof typeof AP
|
|
|
19
18
|
export const PAYMENT_TYPE = {
|
|
20
19
|
SDD_SALE: "SDD_SALE",
|
|
21
20
|
REFUND: "REFUND",
|
|
22
|
-
CHARGEBACK: "CHARGEBACK"
|
|
23
|
-
DEBIT: "DEBIT"
|
|
21
|
+
CHARGEBACK: "CHARGEBACK"
|
|
24
22
|
};
|
|
25
23
|
export type PAYMENT_TYPE = (typeof PAYMENT_TYPE)[keyof typeof PAYMENT_TYPE];
|
|
26
24
|
|
|
@@ -30,7 +28,6 @@ export interface Transaction {
|
|
|
30
28
|
amount?: string;
|
|
31
29
|
currency?: string;
|
|
32
30
|
midId?: number;
|
|
33
|
-
mid?: Mid;
|
|
34
31
|
orderId?: number;
|
|
35
32
|
// internalSubscriptionId?: number;
|
|
36
33
|
internalPaymentType?: PAYMENT_TYPE;
|
package/src/util/constants.ts
CHANGED
|
@@ -110,8 +110,4 @@ export const CURRENCIES = {
|
|
|
110
110
|
USD: "USD",
|
|
111
111
|
GBP: "GBP",
|
|
112
112
|
};
|
|
113
|
-
export type CURRENCIES = (typeof CURRENCIES)[keyof typeof CURRENCIES];
|
|
114
|
-
|
|
115
|
-
export const MB_1 = 1 * 1024 * 1024;
|
|
116
|
-
|
|
117
|
-
export const MAX_MB_STREAM_SIZE = MB_1 * 5;
|
|
113
|
+
export type CURRENCIES = (typeof CURRENCIES)[keyof typeof CURRENCIES];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { format, isValid, parseISO, addDays, subDays } from 'date-fns';
|
|
2
|
+
|
|
3
|
+
export const FORMATS = {
|
|
4
|
+
ISO_DATE: 'yyyy-MM-dd', // "2026-01-07"
|
|
5
|
+
ISO_DATE_TIME_TZ: "yyyy-MM-dd'T'HH:mm", // "2026-01-07T14:30"
|
|
6
|
+
ISO_DATE_TIME_MINUTES: 'yyyy-MM-dd HH:mm', // "2026-01-07 14:30
|
|
7
|
+
ISO_DATE_TIME_SECONDS: 'yyyy-MM-dd HH:mm:ss', // "2026-01-07 14:30:23,
|
|
8
|
+
COMPACT_DATETIME: 'yyyyMMddHHmmss', // "20260107143000"
|
|
9
|
+
COMPACT_DATE: 'yyyyMMdd', // "20260107"
|
|
10
|
+
} as const;
|
|
11
|
+
// ============================================
|
|
12
|
+
// Date → String formatted conversions
|
|
13
|
+
// ============================================
|
|
14
|
+
export function dateToString(date: Date, formatString: string = FORMATS.ISO_DATE): string {
|
|
15
|
+
if (!date || !isValid(date)) {
|
|
16
|
+
throw new Error('Invalid date: ' + date);
|
|
17
|
+
}
|
|
18
|
+
return format(date, formatString);
|
|
19
|
+
}
|
|
20
|
+
export function dateToYYYYMMDD(date: Date): string {
|
|
21
|
+
return dateToString(date, FORMATS.COMPACT_DATETIME);
|
|
22
|
+
}
|
|
23
|
+
export function dateToTZ(date: Date): string {
|
|
24
|
+
return dateToString(date, FORMATS.ISO_DATE_TIME_TZ);
|
|
25
|
+
}
|
|
26
|
+
export function dateToMinutes(date: Date): string {
|
|
27
|
+
return dateToString(date, FORMATS.ISO_DATE_TIME_MINUTES);
|
|
28
|
+
}
|
|
29
|
+
export function getCurrentDateCompacted(): string {
|
|
30
|
+
return dateToYYYYMMDD(new Date()); // "20260107143000"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Checks if a string matches a date pattern
|
|
34
|
+
export function isDateString(value: string): boolean {
|
|
35
|
+
const datePattern = /^\d{4}-\d{2}-\d{2}(T|\s)\d{2}:\d{2}:\d{2}/;
|
|
36
|
+
return datePattern.test(value);
|
|
37
|
+
}
|
|
38
|
+
// ============================================
|
|
39
|
+
// String → Date conversions
|
|
40
|
+
// ============================================
|
|
41
|
+
export function stringToDate(value: string): Date {
|
|
42
|
+
if (!value) {
|
|
43
|
+
throw new Error('Date string cannot be empty');
|
|
44
|
+
}
|
|
45
|
+
const date = parseISO(value);
|
|
46
|
+
if (!isValid(date)) {
|
|
47
|
+
throw new Error('Invalid date string: ' + value);
|
|
48
|
+
}
|
|
49
|
+
return date;
|
|
50
|
+
}
|
|
51
|
+
// ============================================
|
|
52
|
+
// String → String formatted conversions
|
|
53
|
+
// ============================================
|
|
54
|
+
export function formatDateString(value: string, formatString: string = FORMATS.ISO_DATE): string {
|
|
55
|
+
if (!value) {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
const date = stringToDate(value);
|
|
59
|
+
return format(date, formatString);
|
|
60
|
+
}
|
|
61
|
+
export function formatDateAs_yyyymmdd(value: string): string {
|
|
62
|
+
return formatDateString(value, FORMATS.ISO_DATE);
|
|
63
|
+
}
|
|
64
|
+
export function formatDateAs_tz(value: string): string {
|
|
65
|
+
return formatDateString(value, FORMATS.ISO_DATE_TIME_TZ);
|
|
66
|
+
}
|
|
67
|
+
export function formatDateAs_minutes(value: string): string {
|
|
68
|
+
return formatDateString(value, FORMATS.ISO_DATE_TIME_MINUTES);
|
|
69
|
+
}
|
|
70
|
+
export function formatDateAs_seconds(value: string): string {
|
|
71
|
+
return formatDateString(value, FORMATS.ISO_DATE_TIME_SECONDS);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ============================================
|
|
75
|
+
// Date manipulation
|
|
76
|
+
// ============================================
|
|
77
|
+
export function addDaysToDate(date: Date, days: number): Date {
|
|
78
|
+
if (!date || !isValid(date)) {
|
|
79
|
+
throw new Error('Invalid date: ' + date);
|
|
80
|
+
}
|
|
81
|
+
return addDays(date, days);
|
|
82
|
+
}
|
|
83
|
+
export function subtractDaysFromDate(date: Date, days: number): Date {
|
|
84
|
+
if (!date || !isValid(date)) {
|
|
85
|
+
throw new Error('Invalid date: ' + date);
|
|
86
|
+
}
|
|
87
|
+
return subDays(date, days);
|
|
88
|
+
}
|
|
89
|
+
export function addDaysToDateString(value: string, days: number, formatString: string = FORMATS.ISO_DATE): string {
|
|
90
|
+
const date = stringToDate(value);
|
|
91
|
+
const newDate = addDays(date, days);
|
|
92
|
+
return format(newDate, formatString);
|
|
93
|
+
}
|
|
94
|
+
export function subtractDaysFromDateString(value: string, days: number, formatString: string = FORMATS.ISO_DATE): string {
|
|
95
|
+
const date = stringToDate(value);
|
|
96
|
+
const newDate = subDays(date, days);
|
|
97
|
+
return format(newDate, formatString);
|
|
98
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"countryUtil.d.ts","sourceRoot":"","sources":["../../src/util/countryUtil.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,KAAG,MAEhD,CAAC"}
|
package/dist/util/countryUtil.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dateUtil.d.ts","sourceRoot":"","sources":["../../src/util/dateUtil.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO;;;;;;;CAOV,CAAC;AAEX,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAK/E,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAKzF;AAED,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAElD;AAED,wBAAgB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAE5C;AAED,wBAAgB,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAEjD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAExD;AAED,wBAAgB,uBAAuB,IAAI,MAAM,CAE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eAAe,CAC7B,KAAK,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EACrC,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM,CA8BR"}
|
package/src/util/countryUtil.ts
DELETED
package/src/util/dateUtil.ts
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { addDays, addMonths, format, isValid, parseISO, subDays } from 'date-fns';
|
|
2
|
-
|
|
3
|
-
export const FORMATS = {
|
|
4
|
-
ISO_DATE: 'yyyy-MM-dd', // "2026-01-07"
|
|
5
|
-
ISO_DATE_TIME_TZ: "yyyy-MM-dd'T'HH:mm", // "2026-01-07T14:30"
|
|
6
|
-
ISO_DATE_TIME_MINUTES: 'yyyy-MM-dd HH:mm', // "2026-01-07 14:30
|
|
7
|
-
ISO_DATE_TIME_SECONDS: 'yyyy-MM-dd HH:mm:ss', // "2026-01-07 14:30:23,
|
|
8
|
-
COMPACT_DATETIME: 'yyyyMMddHHmmss', // "20260107143000"
|
|
9
|
-
COMPACT_DATE: 'yyyyMMdd', // "20260107"
|
|
10
|
-
} as const;
|
|
11
|
-
|
|
12
|
-
export const INTERVAL_UNIT = {
|
|
13
|
-
DAYS: "DAYS",
|
|
14
|
-
MONTHS: "MONTHS",
|
|
15
|
-
} as const;
|
|
16
|
-
export type INTERVAL_UNIT = (typeof INTERVAL_UNIT)[keyof typeof INTERVAL_UNIT];
|
|
17
|
-
|
|
18
|
-
// ============================================
|
|
19
|
-
// Date → String formatted conversions
|
|
20
|
-
// ============================================
|
|
21
|
-
export function dateToString(date?: Date, formatString: string = FORMATS.ISO_DATE): string {
|
|
22
|
-
if (!date || !isValid(date)) {
|
|
23
|
-
return undefined!;
|
|
24
|
-
}
|
|
25
|
-
return format(date, formatString);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function dateToYYYYMMDD(date?: Date): string {
|
|
29
|
-
return dateToString(date, FORMATS.COMPACT_DATETIME);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function dateToTZ(date?: Date): string {
|
|
33
|
-
return dateToString(date, FORMATS.ISO_DATE_TIME_TZ);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function dateToMinutes(date?: Date): string {
|
|
37
|
-
return dateToString(date, FORMATS.ISO_DATE_TIME_MINUTES);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function dateToMinutesSeconds(date?: Date): string {
|
|
41
|
-
return dateToString(date, FORMATS.ISO_DATE_TIME_SECONDS);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getCurrentDateCompacted(): string {
|
|
45
|
-
return dateToYYYYMMDD(new Date()); // "20260107143000"
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Checks if a string matches a date pattern
|
|
49
|
-
export function isDateString(value: string): boolean {
|
|
50
|
-
const datePattern = /^\d{4}-\d{2}-\d{2}(T|\s)\d{2}:\d{2}:\d{2}/;
|
|
51
|
-
return datePattern.test(value);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ============================================
|
|
55
|
-
// String → Date conversions
|
|
56
|
-
// ============================================
|
|
57
|
-
export function stringToDate(value: string): Date {
|
|
58
|
-
if (!value) {
|
|
59
|
-
throw new Error('Date string cannot be empty');
|
|
60
|
-
}
|
|
61
|
-
const date = parseISO(value);
|
|
62
|
-
if (!isValid(date)) {
|
|
63
|
-
throw new Error('Invalid date string: ' + value);
|
|
64
|
-
}
|
|
65
|
-
return date;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// ============================================
|
|
69
|
-
// String → String formatted conversions
|
|
70
|
-
// ============================================
|
|
71
|
-
export function formatDateString(value: string, formatString: string = FORMATS.ISO_DATE): string {
|
|
72
|
-
if (!value) {
|
|
73
|
-
return '';
|
|
74
|
-
}
|
|
75
|
-
const date = stringToDate(value);
|
|
76
|
-
return format(date, formatString);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function formatDateAs_yyyymmdd(value: string): string {
|
|
80
|
-
return formatDateString(value, FORMATS.ISO_DATE);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function formatDateAs_tz(value: string): string {
|
|
84
|
-
return formatDateString(value, FORMATS.ISO_DATE_TIME_TZ);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function formatDateAs_minutes(value: string): string {
|
|
88
|
-
return formatDateString(value, FORMATS.ISO_DATE_TIME_MINUTES);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function formatDateAs_seconds(value: string): string {
|
|
92
|
-
return formatDateString(value, FORMATS.ISO_DATE_TIME_SECONDS);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// ============================================
|
|
96
|
-
// Date manipulation
|
|
97
|
-
// ============================================
|
|
98
|
-
export function addDaysToDate(date: Date, days: number): Date {
|
|
99
|
-
if (!date || !isValid(date)) {
|
|
100
|
-
throw new Error('Invalid date: ' + date);
|
|
101
|
-
}
|
|
102
|
-
return addDays(date, days);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function subtractDaysFromDate(date: Date, days: number): Date {
|
|
106
|
-
if (!date || !isValid(date)) {
|
|
107
|
-
throw new Error('Invalid date: ' + date);
|
|
108
|
-
}
|
|
109
|
-
return subDays(date, days);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function addDaysToDateString(value: string, days: number, formatString: string = FORMATS.ISO_DATE): string {
|
|
113
|
-
const date = stringToDate(value);
|
|
114
|
-
const newDate = addDays(date, days);
|
|
115
|
-
return format(newDate, formatString);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function subtractDaysFromDateString(value: string, days: number, formatString: string = FORMATS.ISO_DATE): string {
|
|
119
|
-
const date = stringToDate(value);
|
|
120
|
-
const newDate = subDays(date, days);
|
|
121
|
-
return format(newDate, formatString);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export function addMonthsToDate(date: Date, months: number): Date {
|
|
125
|
-
if (!date || !isValid(date)) {
|
|
126
|
-
throw new Error('Invalid date: ' + date);
|
|
127
|
-
}
|
|
128
|
-
return addMonths(date, months);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function addPeriodToDate(date: Date, period: number, unit: INTERVAL_UNIT): Date {
|
|
132
|
-
if (!date || !isValid(date)) {
|
|
133
|
-
throw new Error('Invalid date: ' + date);
|
|
134
|
-
}
|
|
135
|
-
if (unit === INTERVAL_UNIT.MONTHS) {
|
|
136
|
-
date = addMonthsToDate(date, period);
|
|
137
|
-
} else if (unit === INTERVAL_UNIT.DAYS) {
|
|
138
|
-
date = addDaysToDate(date, period);
|
|
139
|
-
}
|
|
140
|
-
return date;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// ============================================
|
|
144
|
-
// UI-friendly formatting (used by admin-ts)
|
|
145
|
-
// ============================================
|
|
146
|
-
|
|
147
|
-
export type UiDateInput = Date | string;
|
|
148
|
-
|
|
149
|
-
//"15 Jan 2024, 10:30:40" or "15 Jan 2024, 10:30" or just "15 Jan 2024".
|
|
150
|
-
|
|
151
|
-
const parseUiDate = (
|
|
152
|
-
value: UiDateInput
|
|
153
|
-
): { date: Date; hasTime: boolean } | null => {
|
|
154
|
-
if (value instanceof Date) {
|
|
155
|
-
const d = value;
|
|
156
|
-
if (Number.isNaN(d.getTime())) return null;
|
|
157
|
-
const hasTime =
|
|
158
|
-
d.getHours() !== 0 ||
|
|
159
|
-
d.getMinutes() !== 0 ||
|
|
160
|
-
d.getSeconds() !== 0 ||
|
|
161
|
-
d.getMilliseconds() !== 0;
|
|
162
|
-
return { date: d, hasTime };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const raw = String(value).trim();
|
|
166
|
-
if (!raw) return null;
|
|
167
|
-
|
|
168
|
-
// Explicit "dd.MM.yyyy" (e.g. "31.07.2024") -> date-only
|
|
169
|
-
const dotDateMatch = raw.match(/^(\d{2})\.(\d{2})\.(\d{4})$/);
|
|
170
|
-
if (dotDateMatch) {
|
|
171
|
-
const [, dd, mm, yyyy] = dotDateMatch;
|
|
172
|
-
const d = new Date(Number(yyyy), Number(mm) - 1, Number(dd));
|
|
173
|
-
if (Number.isNaN(d.getTime())) return null;
|
|
174
|
-
return { date: d, hasTime: false };
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Plain ISO date "YYYY-MM-DD" -> date-only
|
|
178
|
-
const isoDateOnlyMatch = raw.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
179
|
-
if (isoDateOnlyMatch) {
|
|
180
|
-
const [, yyyy, mm, dd] = isoDateOnlyMatch;
|
|
181
|
-
const d = new Date(Number(yyyy), Number(mm) - 1, Number(dd));
|
|
182
|
-
if (Number.isNaN(d.getTime())) return null;
|
|
183
|
-
return { date: d, hasTime: false };
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Fallback to native parser for ISO timestamps and other formats.
|
|
187
|
-
const d = new Date(raw);
|
|
188
|
-
if (Number.isNaN(d.getTime())) return null;
|
|
189
|
-
|
|
190
|
-
// If the original string clearly contained a time (has 'T' or an HH:MM),
|
|
191
|
-
// treat it as having a time component, otherwise fall back to midnight check.
|
|
192
|
-
const explicitTime = /T\d\d?:\d\d/.test(raw) || /\d{1,2}:\d{2}/.test(raw);
|
|
193
|
-
const hasTime =
|
|
194
|
-
explicitTime ||
|
|
195
|
-
d.getHours() !== 0 ||
|
|
196
|
-
d.getMinutes() !== 0 ||
|
|
197
|
-
d.getSeconds() !== 0 ||
|
|
198
|
-
d.getMilliseconds() !== 0;
|
|
199
|
-
|
|
200
|
-
return { date: d, hasTime };
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export type FormatDateForUiOptions = { includeSeconds?: boolean };
|
|
204
|
-
|
|
205
|
-
export function formatDateForUi(
|
|
206
|
-
value: UiDateInput | null | undefined,
|
|
207
|
-
options?: FormatDateForUiOptions
|
|
208
|
-
): string {
|
|
209
|
-
if (!value) {
|
|
210
|
-
return '-';
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const parsed = parseUiDate(value);
|
|
214
|
-
if (!parsed) {
|
|
215
|
-
return '-';
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const { date, hasTime } = parsed;
|
|
219
|
-
const includeSeconds = options?.includeSeconds ?? false;
|
|
220
|
-
|
|
221
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
222
|
-
const monthShort = date.toLocaleString('en-US', { month: 'short' });
|
|
223
|
-
const year = date.getFullYear();
|
|
224
|
-
const base = `${day} ${monthShort} ${year}`;
|
|
225
|
-
|
|
226
|
-
if (!hasTime) {
|
|
227
|
-
return base;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const hours = String(date.getHours()).padStart(2, '0');
|
|
231
|
-
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
232
|
-
const time =
|
|
233
|
-
includeSeconds
|
|
234
|
-
? `${hours}:${minutes}:${String(date.getSeconds()).padStart(2, '0')}`
|
|
235
|
-
: `${hours}:${minutes}`;
|
|
236
|
-
|
|
237
|
-
return `${base}, ${time}`;
|
|
238
|
-
}
|