zavadil-ts-common 1.2.52 → 1.2.53
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.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/util/DateUtil.ts +9 -10
package/src/util/DateUtil.ts
CHANGED
@@ -15,23 +15,22 @@ export class DateUtil {
|
|
15
15
|
return d;
|
16
16
|
}
|
17
17
|
|
18
|
-
static formatDateForHumans(d: Date | string | null | undefined, showTime = false): string {
|
18
|
+
static formatDateForHumans(d: Date | string | null | undefined, showTime: boolean = false): string {
|
19
19
|
d = DateUtil.parseDate(d);
|
20
|
-
if (!d) return
|
20
|
+
if (!d) return '';
|
21
21
|
|
22
22
|
const year = d.getFullYear();
|
23
23
|
const month = DateUtil.formatNumber(d.getMonth() + 1);
|
24
24
|
const day = DateUtil.formatNumber(d.getDate());
|
25
25
|
|
26
|
-
const date = `${year}-${month}-${day}`
|
27
26
|
if (!showTime) {
|
28
|
-
return
|
27
|
+
return `${year}-${month}-${day}`;
|
29
28
|
}
|
30
29
|
|
31
30
|
const hours = DateUtil.formatNumber(d.getHours());
|
32
31
|
const minutes = DateUtil.formatNumber(d.getMinutes());
|
33
32
|
const seconds = DateUtil.formatNumber(d.getSeconds());
|
34
|
-
return `${
|
33
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
35
34
|
}
|
36
35
|
|
37
36
|
static formatDateTimeForHumans(d: Date | string | null | undefined): string {
|
@@ -39,11 +38,11 @@ export class DateUtil {
|
|
39
38
|
}
|
40
39
|
|
41
40
|
static formatDateForInput(d: any, showTime: boolean = false): string {
|
42
|
-
|
43
|
-
if (
|
44
|
-
const year =
|
45
|
-
const month = DateUtil.formatNumber(
|
46
|
-
const day = DateUtil.formatNumber(
|
41
|
+
d = DateUtil.parseDate(d);
|
42
|
+
if (!d) return '';
|
43
|
+
const year = d.getFullYear();
|
44
|
+
const month = DateUtil.formatNumber(d.getMonth() + 1);
|
45
|
+
const day = DateUtil.formatNumber(d.getDate());
|
47
46
|
|
48
47
|
if (!showTime) {
|
49
48
|
return `${year}-${month}-${day}`;
|