@org-quicko/core 2.0.4 → 2.0.5
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/README.md +33 -8
- package/dist/browser/beans/BaseObject.js.map +1 -1
- package/dist/browser/exceptions/BadRequestException.js.map +1 -1
- package/dist/browser/exceptions/BaseException.js.map +1 -1
- package/dist/browser/exceptions/ClientException.js.map +1 -1
- package/dist/browser/exceptions/ConverterException.js.map +1 -1
- package/dist/browser/exceptions/ForbiddenAccessException.js.map +1 -1
- package/dist/browser/exceptions/HTTPException.js.map +1 -1
- package/dist/browser/exceptions/IllegalArgumentException.js.map +1 -1
- package/dist/browser/exceptions/UnauthorizedException.js.map +1 -1
- package/dist/browser/types/JSONObject.js.map +1 -1
- package/dist/browser/types/LoggingLevel.js.map +1 -1
- package/dist/browser/types/SortOrder.js.map +1 -1
- package/dist/browser/utils/date/DateUtil.js +29 -25
- package/dist/browser/utils/date/DateUtil.js.map +1 -1
- package/dist/cjs/beans/BaseObject.cjs.map +1 -1
- package/dist/cjs/exceptions/BadRequestException.cjs.map +1 -1
- package/dist/cjs/exceptions/BaseException.cjs.map +1 -1
- package/dist/cjs/exceptions/ClientException.cjs.map +1 -1
- package/dist/cjs/exceptions/ConverterException.cjs.map +1 -1
- package/dist/cjs/exceptions/ForbiddenAccessException.cjs.map +1 -1
- package/dist/cjs/exceptions/HTTPException.cjs.map +1 -1
- package/dist/cjs/exceptions/IllegalArgumentException.cjs.map +1 -1
- package/dist/cjs/exceptions/UnauthorizedException.cjs.map +1 -1
- package/dist/cjs/logger/LoggerFactory.cjs.map +1 -1
- package/dist/cjs/logger/format/ErrorFormat.cjs.map +1 -1
- package/dist/cjs/types/JSONObject.cjs.map +1 -1
- package/dist/cjs/types/LoggingLevel.cjs.map +1 -1
- package/dist/cjs/types/SortOrder.cjs.map +1 -1
- package/dist/cjs/utils/date/DateUtil.cjs +29 -25
- package/dist/cjs/utils/date/DateUtil.cjs.map +1 -1
- package/dist/esm/beans/BaseObject.js.map +1 -1
- package/dist/esm/exceptions/BadRequestException.js.map +1 -1
- package/dist/esm/exceptions/BaseException.js.map +1 -1
- package/dist/esm/exceptions/ClientException.js.map +1 -1
- package/dist/esm/exceptions/ConverterException.js.map +1 -1
- package/dist/esm/exceptions/ForbiddenAccessException.js.map +1 -1
- package/dist/esm/exceptions/HTTPException.js.map +1 -1
- package/dist/esm/exceptions/IllegalArgumentException.js.map +1 -1
- package/dist/esm/exceptions/UnauthorizedException.js.map +1 -1
- package/dist/esm/logger/LoggerFactory.js.map +1 -1
- package/dist/esm/logger/format/ErrorFormat.js.map +1 -1
- package/dist/esm/types/JSONObject.js.map +1 -1
- package/dist/esm/types/LoggingLevel.js.map +1 -1
- package/dist/esm/types/SortOrder.js.map +1 -1
- package/dist/esm/utils/date/DateUtil.js +29 -25
- package/dist/esm/utils/date/DateUtil.js.map +1 -1
- package/dist/types/src/utils/date/DateUtil.d.ts +38 -17
- package/package.json +115 -140
|
@@ -6,6 +6,7 @@ import { Duration } from 'date-fns';
|
|
|
6
6
|
*/
|
|
7
7
|
declare class DateUtil {
|
|
8
8
|
static readonly ISO_8601_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSxxx";
|
|
9
|
+
static readonly TIMEZONE = "UTC";
|
|
9
10
|
/**
|
|
10
11
|
* Gets the current date and time in the specified time zone.
|
|
11
12
|
* @param timeZone The IANA time zone identifier.
|
|
@@ -59,31 +60,45 @@ declare class DateUtil {
|
|
|
59
60
|
*/
|
|
60
61
|
static isValidDate(dateString: string, dateFormat?: string): boolean;
|
|
61
62
|
/**
|
|
62
|
-
* Calculates the absolute number of days between two dates or timestamps.
|
|
63
|
+
* Calculates the absolute number of calendar days between two dates or timestamps.
|
|
64
|
+
* Since day boundaries depend on a calendar, callers can optionally provide a time zone
|
|
65
|
+
* so the same pair of instants is interpreted consistently across machines.
|
|
66
|
+
*
|
|
63
67
|
* @param firstDate The first date or timestamp.
|
|
64
68
|
* @param secondDate The second date or timestamp.
|
|
69
|
+
* @param timeZone Optional IANA time zone identifier used for calendar comparisons.
|
|
65
70
|
* @returns Number of days between the two dates.
|
|
66
71
|
*/
|
|
67
|
-
static daysInBetween(firstDate: Date, secondDate: Date): number;
|
|
68
|
-
static daysInBetween(firstDate: number, secondDate: number): number;
|
|
72
|
+
static daysInBetween(firstDate: Date, secondDate: Date, timeZone?: string): number;
|
|
73
|
+
static daysInBetween(firstDate: number, secondDate: number, timeZone?: string): number;
|
|
69
74
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
* Calculates the absolute number of calendar months between two dates or timestamps.
|
|
76
|
+
* Since month boundaries depend on a calendar, callers can optionally provide a time zone
|
|
77
|
+
* so the same pair of instants is interpreted consistently across machines.
|
|
78
|
+
*
|
|
79
|
+
* @param firstDate The first date or timestamp.
|
|
80
|
+
* @param secondDate The second date or timestamp.
|
|
81
|
+
* @param timeZone Optional IANA time zone identifier used for calendar comparisons.
|
|
82
|
+
* @returns The number of months between the two dates.
|
|
83
|
+
*/
|
|
84
|
+
static monthsInBetween(firstDate: Date, secondDate: Date, timeZone?: string): number;
|
|
85
|
+
static monthsInBetween(firstDate: number, secondDate: number, timeZone?: string): number;
|
|
77
86
|
/**
|
|
78
|
-
* Calculates the absolute number of years between two dates or timestamps.
|
|
87
|
+
* Calculates the absolute number of calendar years between two dates or timestamps.
|
|
88
|
+
* Since year boundaries depend on a calendar, callers can optionally provide a time zone
|
|
89
|
+
* so the same pair of instants is interpreted consistently across machines.
|
|
90
|
+
*
|
|
79
91
|
* @param firstDate The first date or timestamp.
|
|
80
92
|
* @param secondDate The second date or timestamp.
|
|
93
|
+
* @param timeZone Optional IANA time zone identifier used for calendar comparisons.
|
|
81
94
|
* @returns The number of years between the two dates.
|
|
82
95
|
*/
|
|
83
|
-
static yearsInBetween(firstDate: Date, secondDate: Date): number;
|
|
84
|
-
static yearsInBetween(firstDate: number, secondDate: number): number;
|
|
96
|
+
static yearsInBetween(firstDate: Date, secondDate: Date, timeZone?: string): number;
|
|
97
|
+
static yearsInBetween(firstDate: number, secondDate: number, timeZone?: string): number;
|
|
85
98
|
/**
|
|
86
|
-
* Calculates the absolute number of hours between two dates or timestamps.
|
|
99
|
+
* Calculates the absolute elapsed number of hours between two dates or timestamps.
|
|
100
|
+
* This is duration-based, not calendar-based, so it is independent of time zone.
|
|
101
|
+
*
|
|
87
102
|
* @param firstDate The first date or timestamp.
|
|
88
103
|
* @param secondDate The second date or timestamp.
|
|
89
104
|
* @returns The number of hours between the two dates.
|
|
@@ -91,7 +106,9 @@ declare class DateUtil {
|
|
|
91
106
|
static hoursInBetween(firstDate: Date, secondDate: Date): number;
|
|
92
107
|
static hoursInBetween(firstDate: number, secondDate: number): number;
|
|
93
108
|
/**
|
|
94
|
-
* Calculates the absolute number of seconds between two dates or timestamps.
|
|
109
|
+
* Calculates the absolute elapsed number of seconds between two dates or timestamps.
|
|
110
|
+
* This is duration-based, not calendar-based, so it is independent of time zone.
|
|
111
|
+
*
|
|
95
112
|
* @param firstDate The first date or timestamp.
|
|
96
113
|
* @param secondDate The second date or timestamp.
|
|
97
114
|
* @returns The number of seconds between the two dates.
|
|
@@ -108,12 +125,16 @@ declare class DateUtil {
|
|
|
108
125
|
static compareDates(firstDate: number, secondDate: number): -1 | 0 | 1;
|
|
109
126
|
/**
|
|
110
127
|
* Adds a duration (e.g., days, months, years) to a given date or timestamp.
|
|
128
|
+
* When a time zone is provided, the duration is applied using calendar arithmetic
|
|
129
|
+
* in that time zone so month-end or day-boundary business rules stay aligned locally.
|
|
130
|
+
*
|
|
111
131
|
* @param date The base date or timestamp to which the duration will be added.
|
|
112
132
|
* @param duration An object specifying the duration (e.g., `{ days: 1, months: 2 }`).
|
|
133
|
+
* @param timeZone Optional IANA time zone identifier used for calendar math.
|
|
113
134
|
* @returns A new Date object with the duration added.
|
|
114
135
|
*/
|
|
115
|
-
static addDuration(date: Date, duration: Duration): Date;
|
|
116
|
-
static addDuration(date: number, duration: Duration): Date;
|
|
136
|
+
static addDuration(date: Date, duration: Duration, timeZone?: string): Date;
|
|
137
|
+
static addDuration(date: number, duration: Duration, timeZone?: string): Date;
|
|
117
138
|
/**
|
|
118
139
|
* Determines whether a given year is a leap year.
|
|
119
140
|
* @param year The year to check.
|
package/package.json
CHANGED
|
@@ -1,140 +1,115 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@org-quicko/core",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "A library in typescript for common entities and utilities across Quicko",
|
|
5
|
-
"author": "Quicko",
|
|
6
|
-
"main": "dist/cjs/build/node/index.cjs",
|
|
7
|
-
"module": "dist/esm/build/node/index.js",
|
|
8
|
-
"browser": "dist/browser/build/browser/index.js",
|
|
9
|
-
"types": "dist/types/index.d.ts",
|
|
10
|
-
"type": "module",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"clean": "rm -rf dist
|
|
13
|
-
"
|
|
14
|
-
"lint
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
"node": "
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"date-fns": "^4.1.0",
|
|
117
|
-
"tslib": "^2.8.1",
|
|
118
|
-
"winston": "^3.17.0"
|
|
119
|
-
},
|
|
120
|
-
"devDependencies": {
|
|
121
|
-
"@rollup/plugin-commonjs": "^28.0.3",
|
|
122
|
-
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
123
|
-
"@rollup/plugin-typescript": "^12.1.2",
|
|
124
|
-
"@types/node": "^22.7.0",
|
|
125
|
-
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
126
|
-
"@typescript-eslint/parser": "^8.33.1",
|
|
127
|
-
"esbuild-plugin-eslint": "^0.3.7",
|
|
128
|
-
"eslint": "^9.28.0",
|
|
129
|
-
"eslint-config-prettier": "^10.1.5",
|
|
130
|
-
"eslint-import-resolver-typescript": "^3.7.0",
|
|
131
|
-
"glob": "^11.0.2",
|
|
132
|
-
"rollup": "^4.40.2",
|
|
133
|
-
"rollup-plugin-dts": "^6.2.1",
|
|
134
|
-
"ts-node": "^10.9.2",
|
|
135
|
-
"typescript": "^5.6.2",
|
|
136
|
-
"@types/jest": "^29.5.12",
|
|
137
|
-
"jest": "^29.7.0",
|
|
138
|
-
"ts-jest": "^29.2.5"
|
|
139
|
-
}
|
|
140
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@org-quicko/core",
|
|
3
|
+
"version": "2.0.5",
|
|
4
|
+
"description": "A library in typescript for common entities and utilities across Quicko",
|
|
5
|
+
"author": "Quicko",
|
|
6
|
+
"main": "dist/cjs/build/node/index.cjs",
|
|
7
|
+
"module": "dist/esm/build/node/index.js",
|
|
8
|
+
"browser": "dist/browser/build/browser/index.js",
|
|
9
|
+
"types": "dist/types/index.d.ts",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"clean": "rm -rf ./dist",
|
|
13
|
+
"clean:all": "rm -rf ./node_modules ./package-lock.json ./dist && npm cache clean --force",
|
|
14
|
+
"lint": "eslint .",
|
|
15
|
+
"lint:fix": "eslint . --fix",
|
|
16
|
+
"prebuild": "npm run clean && npm run lint",
|
|
17
|
+
"build": "rollup -c",
|
|
18
|
+
"test": "set NODE_ENV=local && node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
19
|
+
"test:date:util": "set NODE_ENV=local && node --experimental-vm-modules node_modules/jest/bin/jest.js run ./tests/DateUtil.test.ts"
|
|
20
|
+
},
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/**/*"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"node": {
|
|
29
|
+
"import": "./dist/esm/build/node/index.js",
|
|
30
|
+
"require": "./dist/cjs/build/node/index.cjs"
|
|
31
|
+
},
|
|
32
|
+
"default": "./dist/browser/build/browser/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./beans": {
|
|
35
|
+
"types": "./dist/types/src/beans/index.d.ts",
|
|
36
|
+
"node": {
|
|
37
|
+
"import": "./dist/esm/beans/index.js",
|
|
38
|
+
"require": "./dist/cjs/beans/index.cjs"
|
|
39
|
+
},
|
|
40
|
+
"default": "./dist/browser/beans/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./types": {
|
|
43
|
+
"types": "./dist/types/src/types/index.d.ts",
|
|
44
|
+
"node": {
|
|
45
|
+
"import": "./dist/esm/types/index.js",
|
|
46
|
+
"require": "./dist/cjs/types/index.cjs"
|
|
47
|
+
},
|
|
48
|
+
"default": "./dist/browser/types/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./utils": {
|
|
51
|
+
"types": "./dist/types/src/utils/index.d.ts",
|
|
52
|
+
"node": {
|
|
53
|
+
"import": "./dist/esm/utils/index.js",
|
|
54
|
+
"require": "./dist/cjs/utils/index.cjs"
|
|
55
|
+
},
|
|
56
|
+
"default": "./dist/browser/utils/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./utils/date": {
|
|
59
|
+
"types": "./dist/types/src/utils/date/index.d.ts",
|
|
60
|
+
"node": {
|
|
61
|
+
"import": "./dist/esm/utils/date/index.js",
|
|
62
|
+
"require": "./dist/cjs/utils/date/index.cjs"
|
|
63
|
+
},
|
|
64
|
+
"default": "./dist/browser/utils/date/index.js"
|
|
65
|
+
},
|
|
66
|
+
"./logger": {
|
|
67
|
+
"types": "./dist/types/src/logger/index.d.ts",
|
|
68
|
+
"node": {
|
|
69
|
+
"import": "./dist/esm/logger/index.js",
|
|
70
|
+
"require": "./dist/cjs/logger/index.cjs"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"./exceptions": {
|
|
74
|
+
"types": "./dist/types/src/exceptions/index.d.ts",
|
|
75
|
+
"node": {
|
|
76
|
+
"import": "./dist/esm/exceptions/index.js",
|
|
77
|
+
"require": "./dist/cjs/exceptions/index.cjs"
|
|
78
|
+
},
|
|
79
|
+
"default": "./dist/browser/exceptions/index.js"
|
|
80
|
+
},
|
|
81
|
+
"./package.json": "./package.json"
|
|
82
|
+
},
|
|
83
|
+
"directories": {
|
|
84
|
+
"lib": "./dist"
|
|
85
|
+
},
|
|
86
|
+
"dependencies": {
|
|
87
|
+
"@date-fns/tz": "^1.1.2",
|
|
88
|
+
"class-transformer": "^0.5.1",
|
|
89
|
+
"class-validator": "^0.14.1",
|
|
90
|
+
"date-fns": "^4.1.0",
|
|
91
|
+
"tslib": "^2.8.1",
|
|
92
|
+
"winston": "^3.17.0"
|
|
93
|
+
},
|
|
94
|
+
"devDependencies": {
|
|
95
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
96
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
97
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
98
|
+
"@types/jest": "^29.5.12",
|
|
99
|
+
"@types/node": "^22.7.0",
|
|
100
|
+
"@typescript-eslint/eslint-plugin": "^8.33.1",
|
|
101
|
+
"@typescript-eslint/parser": "^8.33.1",
|
|
102
|
+
"esbuild-plugin-eslint": "^0.3.7",
|
|
103
|
+
"eslint": "^9.28.0",
|
|
104
|
+
"eslint-config-prettier": "^10.1.5",
|
|
105
|
+
"eslint-import-resolver-typescript": "^3.7.0",
|
|
106
|
+
"glob": "^11.0.2",
|
|
107
|
+
"jest": "^29.7.0",
|
|
108
|
+
"rollup": "^4.40.2",
|
|
109
|
+
"rollup-plugin-dts": "^6.2.1",
|
|
110
|
+
"rollup-plugin-node-externals": "^8.1.2",
|
|
111
|
+
"ts-jest": "^29.2.5",
|
|
112
|
+
"ts-node": "^10.9.2",
|
|
113
|
+
"typescript": "^5.6.2"
|
|
114
|
+
}
|
|
115
|
+
}
|