fix(datetime): default to current date when value is null (#18105)

fixes #18099
This commit is contained in:
Liam DeBeasi
2019-04-23 13:12:17 -04:00
committed by GitHub
parent 464ec3b70a
commit ca233b547a
2 changed files with 23 additions and 1 deletions

View File

@ -248,6 +248,17 @@ export function parseDate(val: string | undefined | null): DatetimeData | undefi
* such as "01:47"
*/
export const getLocalDateTime = (dateString: any = ''): Date => {
/**
* If user passed in undefined
* or null, convert it to the
* empty string since the rest
* of this functions expects
* a string
*/
if (dateString === undefined || dateString === null) {
dateString = '';
}
/**
* Ensures that YYYY-MM-DD, YYYY-MM,
* YYYY-DD, etc does not get affected