fix(datetime): ensure year-only values are not affected by timezone when parsing (#21309)

This commit is contained in:
Liam DeBeasi
2020-05-15 11:36:01 -04:00
committed by GitHub
parent 16a03d58ec
commit 3937101e5c
2 changed files with 6 additions and 5 deletions

View File

@ -262,13 +262,14 @@ export const getDateTime = (dateString: any = '', timeZone: any = ''): Date => {
/**
* Ensures that YYYY-MM-DD, YYYY-MM,
* YYYY-DD, etc does not get affected
* YYYY-DD, YYYY, etc does not get affected
* by timezones and stays on the day/month
* that the user provided
*/
if (
dateString.length === 10 ||
dateString.length === 7
dateString.length === 7 ||
dateString.length === 4
) {
dateString += ' ';
}

View File

@ -64,7 +64,7 @@
<ion-item>
<ion-label>YYYY</ion-label>
<ion-datetime id="customPickerOptions" placeholder="Custom Options" display-format="YYYY" min="1981" max="2002"></ion-datetime>
<ion-datetime id="customPickerOptions" placeholder="Custom Options" display-format="YYYY" min="1981" max="2002" value="2000"></ion-datetime>
</ion-item>
<ion-item>