Commit 350c85accf5033cc5a21b71bc36d5b7a74eb2573
Committed by
GitHub
1 parent
202aa42b
fix(utils): The date function gets a non-date when the parameter is null (#954)
Co-authored-by: “weilin <“784742294@qq.com>
Showing
1 changed file
with
2 additions
and
2 deletions
src/utils/dateUtil.ts
@@ -7,13 +7,13 @@ const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm'; | @@ -7,13 +7,13 @@ const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm'; | ||
7 | const DATE_FORMAT = 'YYYY-MM-DD '; | 7 | const DATE_FORMAT = 'YYYY-MM-DD '; |
8 | 8 | ||
9 | export function formatToDateTime( | 9 | export function formatToDateTime( |
10 | - date: moment.MomentInput = null, | 10 | + date: moment.MomentInput = undefined, |
11 | format = DATE_TIME_FORMAT | 11 | format = DATE_TIME_FORMAT |
12 | ): string { | 12 | ): string { |
13 | return moment(date).format(format); | 13 | return moment(date).format(format); |
14 | } | 14 | } |
15 | 15 | ||
16 | -export function formatToDate(date: moment.MomentInput = null, format = DATE_FORMAT): string { | 16 | +export function formatToDate(date: moment.MomentInput = undefined, format = DATE_FORMAT): string { |
17 | return moment(date).format(format); | 17 | return moment(date).format(format); |
18 | } | 18 | } |
19 | 19 |