@rocketlink/crm-model 1.0.124 → 1.0.125
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/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 +2 -6
- package/dist/model/recurringSettingConfig.model.d.ts.map +1 -1
- package/dist/model/recurringSettingConfig.model.js +0 -5
- package/dist/util/countryUtil.d.ts +2 -0
- package/dist/util/countryUtil.d.ts.map +1 -0
- package/dist/util/countryUtil.js +7 -0
- package/dist/util/{dateUtils.d.ts → dateUtil.d.ts} +13 -5
- package/dist/util/dateUtil.d.ts.map +1 -0
- package/dist/util/{dateUtils.js → dateUtil.js} +30 -2
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/model/recurringSettingConfig.model.ts +2 -6
- package/src/util/countryUtil.ts +3 -0
- package/src/util/{dateUtils.ts → dateUtil.ts} +49 -6
- package/dist/util/dateUtils.d.ts.map +0 -1
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/dateUtil';
|
|
3
|
+
export { isDateString, dateToString, stringToDate, getCurrentDateCompacted, FORMATS } from './util/dateUtil';
|
|
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,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,kBA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AuB,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/dateUtil"), exports);
|
|
21
|
+
var dateUtil_1 = require("./util/dateUtil");
|
|
22
|
+
Object.defineProperty(exports, "isDateString", { enumerable: true, get: function () { return dateUtil_1.isDateString; } });
|
|
23
|
+
Object.defineProperty(exports, "dateToString", { enumerable: true, get: function () { return dateUtil_1.dateToString; } });
|
|
24
|
+
Object.defineProperty(exports, "stringToDate", { enumerable: true, get: function () { return dateUtil_1.stringToDate; } });
|
|
25
|
+
Object.defineProperty(exports, "getCurrentDateCompacted", { enumerable: true, get: function () { return dateUtil_1.getCurrentDateCompacted; } });
|
|
26
|
+
Object.defineProperty(exports, "FORMATS", { enumerable: true, get: function () { return dateUtil_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,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
readonly DAYS: "DAYS";
|
|
3
|
-
readonly MONTHS: "MONTHS";
|
|
4
|
-
};
|
|
5
|
-
export type INTERVAL_UNIT = (typeof INTERVAL_UNIT)[keyof typeof INTERVAL_UNIT];
|
|
1
|
+
import * as dateUtil from "../util/dateUtil";
|
|
6
2
|
export interface RecurringSettingConfig {
|
|
7
3
|
id?: number;
|
|
8
4
|
name?: string;
|
|
9
|
-
intervalUnit?: INTERVAL_UNIT;
|
|
5
|
+
intervalUnit?: dateUtil.INTERVAL_UNIT;
|
|
10
6
|
intervalPeriod?: number;
|
|
11
7
|
maxTriesAfterFailure?: number;
|
|
12
8
|
maxDelayPeriod?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recurringSettingConfig.model.d.ts","sourceRoot":"","sources":["../../src/model/recurringSettingConfig.model.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"recurringSettingConfig.model.d.ts","sourceRoot":"","sources":["../../src/model/recurringSettingConfig.model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,sBAAsB;IACrC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC;IACtC,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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -6,10 +6,16 @@ export declare const FORMATS: {
|
|
|
6
6
|
readonly COMPACT_DATETIME: "yyyyMMddHHmmss";
|
|
7
7
|
readonly COMPACT_DATE: "yyyyMMdd";
|
|
8
8
|
};
|
|
9
|
-
export declare
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export declare const INTERVAL_UNIT: {
|
|
10
|
+
readonly DAYS: "DAYS";
|
|
11
|
+
readonly MONTHS: "MONTHS";
|
|
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;
|
|
13
19
|
export declare function getCurrentDateCompacted(): string;
|
|
14
20
|
export declare function isDateString(value: string): boolean;
|
|
15
21
|
export declare function stringToDate(value: string): Date;
|
|
@@ -22,4 +28,6 @@ export declare function addDaysToDate(date: Date, days: number): Date;
|
|
|
22
28
|
export declare function subtractDaysFromDate(date: Date, days: number): Date;
|
|
23
29
|
export declare function addDaysToDateString(value: string, days: number, formatString?: string): string;
|
|
24
30
|
export declare function subtractDaysFromDateString(value: string, days: number, formatString?: string): string;
|
|
25
|
-
|
|
31
|
+
export declare function addMonthsToDate(date: Date, months: number): Date;
|
|
32
|
+
export declare function addPeriodToDate(date: Date, period: number, unit: INTERVAL_UNIT): Date;
|
|
33
|
+
//# sourceMappingURL=dateUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAEhD;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnD;AAKD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAShD;AAKD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAM/F;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AAKD,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAK5D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAKnE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAIhH;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAIvH;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAKhE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,CAUrF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FORMATS = void 0;
|
|
3
|
+
exports.INTERVAL_UNIT = 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;
|
|
8
9
|
exports.getCurrentDateCompacted = getCurrentDateCompacted;
|
|
9
10
|
exports.isDateString = isDateString;
|
|
10
11
|
exports.stringToDate = stringToDate;
|
|
@@ -17,6 +18,8 @@ exports.addDaysToDate = addDaysToDate;
|
|
|
17
18
|
exports.subtractDaysFromDate = subtractDaysFromDate;
|
|
18
19
|
exports.addDaysToDateString = addDaysToDateString;
|
|
19
20
|
exports.subtractDaysFromDateString = subtractDaysFromDateString;
|
|
21
|
+
exports.addMonthsToDate = addMonthsToDate;
|
|
22
|
+
exports.addPeriodToDate = addPeriodToDate;
|
|
20
23
|
const date_fns_1 = require("date-fns");
|
|
21
24
|
exports.FORMATS = {
|
|
22
25
|
ISO_DATE: 'yyyy-MM-dd', // "2026-01-07"
|
|
@@ -26,12 +29,16 @@ exports.FORMATS = {
|
|
|
26
29
|
COMPACT_DATETIME: 'yyyyMMddHHmmss', // "20260107143000"
|
|
27
30
|
COMPACT_DATE: 'yyyyMMdd', // "20260107"
|
|
28
31
|
};
|
|
32
|
+
exports.INTERVAL_UNIT = {
|
|
33
|
+
DAYS: "DAYS",
|
|
34
|
+
MONTHS: "MONTHS",
|
|
35
|
+
};
|
|
29
36
|
// ============================================
|
|
30
37
|
// Date → String formatted conversions
|
|
31
38
|
// ============================================
|
|
32
39
|
function dateToString(date, formatString = exports.FORMATS.ISO_DATE) {
|
|
33
40
|
if (!date || !(0, date_fns_1.isValid)(date)) {
|
|
34
|
-
|
|
41
|
+
return undefined;
|
|
35
42
|
}
|
|
36
43
|
return (0, date_fns_1.format)(date, formatString);
|
|
37
44
|
}
|
|
@@ -44,6 +51,9 @@ function dateToTZ(date) {
|
|
|
44
51
|
function dateToMinutes(date) {
|
|
45
52
|
return dateToString(date, exports.FORMATS.ISO_DATE_TIME_MINUTES);
|
|
46
53
|
}
|
|
54
|
+
function dateToMinutesSeconds(date) {
|
|
55
|
+
return dateToString(date, exports.FORMATS.ISO_DATE_TIME_SECONDS);
|
|
56
|
+
}
|
|
47
57
|
function getCurrentDateCompacted() {
|
|
48
58
|
return dateToYYYYMMDD(new Date()); // "20260107143000"
|
|
49
59
|
}
|
|
@@ -112,3 +122,21 @@ function subtractDaysFromDateString(value, days, formatString = exports.FORMATS.
|
|
|
112
122
|
const newDate = (0, date_fns_1.subDays)(date, days);
|
|
113
123
|
return (0, date_fns_1.format)(newDate, formatString);
|
|
114
124
|
}
|
|
125
|
+
function addMonthsToDate(date, months) {
|
|
126
|
+
if (!date || !(0, date_fns_1.isValid)(date)) {
|
|
127
|
+
throw new Error('Invalid date: ' + date);
|
|
128
|
+
}
|
|
129
|
+
return (0, date_fns_1.addMonths)(date, months);
|
|
130
|
+
}
|
|
131
|
+
function addPeriodToDate(date, period, unit) {
|
|
132
|
+
if (!date || !(0, date_fns_1.isValid)(date)) {
|
|
133
|
+
throw new Error('Invalid date: ' + date);
|
|
134
|
+
}
|
|
135
|
+
if (unit === exports.INTERVAL_UNIT.MONTHS) {
|
|
136
|
+
date = addMonthsToDate(date, period);
|
|
137
|
+
}
|
|
138
|
+
else if (unit === exports.INTERVAL_UNIT.DAYS) {
|
|
139
|
+
date = addDaysToDate(date, period);
|
|
140
|
+
}
|
|
141
|
+
return date;
|
|
142
|
+
}
|
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/dateUtil';
|
|
4
|
+
export { isDateString, dateToString, stringToDate, getCurrentDateCompacted, FORMATS } from './util/dateUtil';
|
|
5
5
|
export * from './util/numberUtils';
|
|
6
6
|
|
|
7
7
|
// Export all DTOs
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
DAYS: "DAYS",
|
|
3
|
-
MONTHS: "MONTHS",
|
|
4
|
-
} as const;
|
|
5
|
-
export type INTERVAL_UNIT = (typeof INTERVAL_UNIT)[keyof typeof INTERVAL_UNIT];
|
|
1
|
+
import * as dateUtil from "../util/dateUtil";
|
|
6
2
|
|
|
7
3
|
export interface RecurringSettingConfig {
|
|
8
4
|
id?: number;
|
|
9
5
|
name?: string;
|
|
10
|
-
intervalUnit?: INTERVAL_UNIT;
|
|
6
|
+
intervalUnit?: dateUtil.INTERVAL_UNIT;
|
|
11
7
|
intervalPeriod?: number;
|
|
12
8
|
maxTriesAfterFailure?: number;
|
|
13
9
|
maxDelayPeriod?: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { format, isValid, parseISO,
|
|
1
|
+
import { addDays, addMonths, format, isValid, parseISO, subDays } from 'date-fns';
|
|
2
2
|
|
|
3
3
|
export const FORMATS = {
|
|
4
4
|
ISO_DATE: 'yyyy-MM-dd', // "2026-01-07"
|
|
@@ -8,24 +8,39 @@ export const FORMATS = {
|
|
|
8
8
|
COMPACT_DATETIME: 'yyyyMMddHHmmss', // "20260107143000"
|
|
9
9
|
COMPACT_DATE: 'yyyyMMdd', // "20260107"
|
|
10
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
|
+
|
|
11
18
|
// ============================================
|
|
12
19
|
// Date → String formatted conversions
|
|
13
20
|
// ============================================
|
|
14
|
-
export function dateToString(date
|
|
21
|
+
export function dateToString(date?: Date, formatString: string = FORMATS.ISO_DATE): string {
|
|
15
22
|
if (!date || !isValid(date)) {
|
|
16
|
-
|
|
23
|
+
return undefined!;
|
|
17
24
|
}
|
|
18
25
|
return format(date, formatString);
|
|
19
26
|
}
|
|
20
|
-
|
|
27
|
+
|
|
28
|
+
export function dateToYYYYMMDD(date?: Date): string {
|
|
21
29
|
return dateToString(date, FORMATS.COMPACT_DATETIME);
|
|
22
30
|
}
|
|
23
|
-
|
|
31
|
+
|
|
32
|
+
export function dateToTZ(date?: Date): string {
|
|
24
33
|
return dateToString(date, FORMATS.ISO_DATE_TIME_TZ);
|
|
25
34
|
}
|
|
26
|
-
|
|
35
|
+
|
|
36
|
+
export function dateToMinutes(date?: Date): string {
|
|
27
37
|
return dateToString(date, FORMATS.ISO_DATE_TIME_MINUTES);
|
|
28
38
|
}
|
|
39
|
+
|
|
40
|
+
export function dateToMinutesSeconds(date?: Date): string {
|
|
41
|
+
return dateToString(date, FORMATS.ISO_DATE_TIME_SECONDS);
|
|
42
|
+
}
|
|
43
|
+
|
|
29
44
|
export function getCurrentDateCompacted(): string {
|
|
30
45
|
return dateToYYYYMMDD(new Date()); // "20260107143000"
|
|
31
46
|
}
|
|
@@ -35,6 +50,7 @@ export function isDateString(value: string): boolean {
|
|
|
35
50
|
const datePattern = /^\d{4}-\d{2}-\d{2}(T|\s)\d{2}:\d{2}:\d{2}/;
|
|
36
51
|
return datePattern.test(value);
|
|
37
52
|
}
|
|
53
|
+
|
|
38
54
|
// ============================================
|
|
39
55
|
// String → Date conversions
|
|
40
56
|
// ============================================
|
|
@@ -48,6 +64,7 @@ export function stringToDate(value: string): Date {
|
|
|
48
64
|
}
|
|
49
65
|
return date;
|
|
50
66
|
}
|
|
67
|
+
|
|
51
68
|
// ============================================
|
|
52
69
|
// String → String formatted conversions
|
|
53
70
|
// ============================================
|
|
@@ -58,15 +75,19 @@ export function formatDateString(value: string, formatString: string = FORMATS.I
|
|
|
58
75
|
const date = stringToDate(value);
|
|
59
76
|
return format(date, formatString);
|
|
60
77
|
}
|
|
78
|
+
|
|
61
79
|
export function formatDateAs_yyyymmdd(value: string): string {
|
|
62
80
|
return formatDateString(value, FORMATS.ISO_DATE);
|
|
63
81
|
}
|
|
82
|
+
|
|
64
83
|
export function formatDateAs_tz(value: string): string {
|
|
65
84
|
return formatDateString(value, FORMATS.ISO_DATE_TIME_TZ);
|
|
66
85
|
}
|
|
86
|
+
|
|
67
87
|
export function formatDateAs_minutes(value: string): string {
|
|
68
88
|
return formatDateString(value, FORMATS.ISO_DATE_TIME_MINUTES);
|
|
69
89
|
}
|
|
90
|
+
|
|
70
91
|
export function formatDateAs_seconds(value: string): string {
|
|
71
92
|
return formatDateString(value, FORMATS.ISO_DATE_TIME_SECONDS);
|
|
72
93
|
}
|
|
@@ -80,19 +101,41 @@ export function addDaysToDate(date: Date, days: number): Date {
|
|
|
80
101
|
}
|
|
81
102
|
return addDays(date, days);
|
|
82
103
|
}
|
|
104
|
+
|
|
83
105
|
export function subtractDaysFromDate(date: Date, days: number): Date {
|
|
84
106
|
if (!date || !isValid(date)) {
|
|
85
107
|
throw new Error('Invalid date: ' + date);
|
|
86
108
|
}
|
|
87
109
|
return subDays(date, days);
|
|
88
110
|
}
|
|
111
|
+
|
|
89
112
|
export function addDaysToDateString(value: string, days: number, formatString: string = FORMATS.ISO_DATE): string {
|
|
90
113
|
const date = stringToDate(value);
|
|
91
114
|
const newDate = addDays(date, days);
|
|
92
115
|
return format(newDate, formatString);
|
|
93
116
|
}
|
|
117
|
+
|
|
94
118
|
export function subtractDaysFromDateString(value: string, days: number, formatString: string = FORMATS.ISO_DATE): string {
|
|
95
119
|
const date = stringToDate(value);
|
|
96
120
|
const newDate = subDays(date, days);
|
|
97
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;
|
|
98
141
|
}
|
|
@@ -1 +0,0 @@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