mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
fix(datetime): ensure year-only values are not affected by timezone when parsing (#21309)
This commit is contained in:
@ -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 += ' ';
|
||||
}
|
||||
|
||||
@ -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>
|
||||
@ -242,10 +242,10 @@
|
||||
var selectedLang = "en";
|
||||
var customDayShortNames = document.getElementById('customMonthShortNames');
|
||||
customDayShortNames.monthShortNames = monthShortNamesEnglish;
|
||||
|
||||
|
||||
function toggleLanguage() {
|
||||
selectedLang = selectedLang === 'en' ? 'fr' : 'en';
|
||||
|
||||
|
||||
var customMonthShortNames = document.getElementById('customMonthShortNames');
|
||||
var el = document.getElementById('selectedLang');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user