mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 22:17:40 +08:00
fix(datetime): default to current date when no value given (#17443)
* fix(datetime): default to current date when no value given * test(datetime): add spec test * move getDateValue to utils
This commit is contained in:
@ -1,3 +1,16 @@
|
||||
/**
|
||||
* Gets a date value given a format
|
||||
* Defaults to the current date if
|
||||
* no date given
|
||||
*/
|
||||
export function getDateValue(date: DatetimeData, format: string): number {
|
||||
const getValue = getValueFromFormat(date, format);
|
||||
|
||||
if (getValue) { return getValue; }
|
||||
|
||||
const defaultDate = parseDate(new Date().toISOString());
|
||||
return getValueFromFormat((defaultDate as DatetimeData), format);
|
||||
}
|
||||
|
||||
export function renderDatetime(template: string, value: DatetimeData | undefined, locale: LocaleData): string | undefined {
|
||||
if (value === undefined) {
|
||||
|
Reference in New Issue
Block a user