@etsoo/shared 1.1.95 → 1.1.96
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/__tests__/DateUtils.ts +6 -0
- package/lib/cjs/DateUtils.d.ts +1 -1
- package/lib/cjs/DateUtils.js +3 -2
- package/lib/mjs/DateUtils.d.ts +1 -1
- package/lib/mjs/DateUtils.js +3 -2
- package/package.json +3 -3
- package/src/DateUtils.ts +3 -3
package/__tests__/DateUtils.ts
CHANGED
|
@@ -71,6 +71,12 @@ test('Tests for formatForInput', () => {
|
|
|
71
71
|
|
|
72
72
|
const result41 = DateUtils.formatForInput(d, 'datetime-local');
|
|
73
73
|
expect(result41).toBe('2021-06-06T20:08:45');
|
|
74
|
+
|
|
75
|
+
const result5 = DateUtils.formatForInput('');
|
|
76
|
+
expect(result5).toBeUndefined();
|
|
77
|
+
|
|
78
|
+
const result51 = DateUtils.formatForInput(null);
|
|
79
|
+
expect(result51).toBeUndefined();
|
|
74
80
|
});
|
|
75
81
|
|
|
76
82
|
test('Tests for isExpired', () => {
|
package/lib/cjs/DateUtils.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare namespace DateUtils {
|
|
|
49
49
|
* @param date Input date
|
|
50
50
|
* @param hasSecondOrType 'undefined' for date only, 'false' for hour:minute only, 'true' for all, or input field type
|
|
51
51
|
*/
|
|
52
|
-
function formatForInput(date?: Date | string | null, hasSecondOrType?: boolean | string): string;
|
|
52
|
+
function formatForInput(date?: Date | string | null, hasSecondOrType?: boolean | string): string | undefined;
|
|
53
53
|
/**
|
|
54
54
|
* Get month's days
|
|
55
55
|
* @param year Year
|
package/lib/cjs/DateUtils.js
CHANGED
|
@@ -97,11 +97,12 @@ var DateUtils;
|
|
|
97
97
|
* @param hasSecondOrType 'undefined' for date only, 'false' for hour:minute only, 'true' for all, or input field type
|
|
98
98
|
*/
|
|
99
99
|
function formatForInput(date, hasSecondOrType) {
|
|
100
|
+
// Return when null
|
|
101
|
+
if (date == null || date === '')
|
|
102
|
+
return undefined;
|
|
100
103
|
// Parse string as date
|
|
101
104
|
if (typeof date === 'string')
|
|
102
105
|
date = new Date(date);
|
|
103
|
-
// Default is now
|
|
104
|
-
date !== null && date !== void 0 ? date : (date = new Date());
|
|
105
106
|
const hasSecond = typeof hasSecondOrType === 'string'
|
|
106
107
|
? hasSecondOrType === 'date'
|
|
107
108
|
? undefined
|
package/lib/mjs/DateUtils.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare namespace DateUtils {
|
|
|
49
49
|
* @param date Input date
|
|
50
50
|
* @param hasSecondOrType 'undefined' for date only, 'false' for hour:minute only, 'true' for all, or input field type
|
|
51
51
|
*/
|
|
52
|
-
function formatForInput(date?: Date | string | null, hasSecondOrType?: boolean | string): string;
|
|
52
|
+
function formatForInput(date?: Date | string | null, hasSecondOrType?: boolean | string): string | undefined;
|
|
53
53
|
/**
|
|
54
54
|
* Get month's days
|
|
55
55
|
* @param year Year
|
package/lib/mjs/DateUtils.js
CHANGED
|
@@ -94,11 +94,12 @@ export var DateUtils;
|
|
|
94
94
|
* @param hasSecondOrType 'undefined' for date only, 'false' for hour:minute only, 'true' for all, or input field type
|
|
95
95
|
*/
|
|
96
96
|
function formatForInput(date, hasSecondOrType) {
|
|
97
|
+
// Return when null
|
|
98
|
+
if (date == null || date === '')
|
|
99
|
+
return undefined;
|
|
97
100
|
// Parse string as date
|
|
98
101
|
if (typeof date === 'string')
|
|
99
102
|
date = new Date(date);
|
|
100
|
-
// Default is now
|
|
101
|
-
date !== null && date !== void 0 ? date : (date = new Date());
|
|
102
103
|
const hasSecond = typeof hasSecondOrType === 'string'
|
|
103
104
|
? hasSecondOrType === 'date'
|
|
104
105
|
? undefined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/shared",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.96",
|
|
4
4
|
"description": "TypeScript shared utilities and functions",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@types/lodash.isequal": "^4.5.6",
|
|
59
59
|
"jest": "^29.5.0",
|
|
60
60
|
"jest-environment-jsdom": "^29.5.0",
|
|
61
|
-
"ts-jest": "^29.0
|
|
62
|
-
"typescript": "^5.0.
|
|
61
|
+
"ts-jest": "^29.1.0",
|
|
62
|
+
"typescript": "^5.0.3"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"lodash.isequal": "^4.5.0"
|
package/src/DateUtils.ts
CHANGED
|
@@ -153,12 +153,12 @@ export namespace DateUtils {
|
|
|
153
153
|
date?: Date | string | null,
|
|
154
154
|
hasSecondOrType?: boolean | string
|
|
155
155
|
) {
|
|
156
|
+
// Return when null
|
|
157
|
+
if (date == null || date === '') return undefined;
|
|
158
|
+
|
|
156
159
|
// Parse string as date
|
|
157
160
|
if (typeof date === 'string') date = new Date(date);
|
|
158
161
|
|
|
159
|
-
// Default is now
|
|
160
|
-
date ??= new Date();
|
|
161
|
-
|
|
162
162
|
const hasSecond =
|
|
163
163
|
typeof hasSecondOrType === 'string'
|
|
164
164
|
? hasSecondOrType === 'date'
|