mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +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,
|
* 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
|
* by timezones and stays on the day/month
|
||||||
* that the user provided
|
* that the user provided
|
||||||
*/
|
*/
|
||||||
if (
|
if (
|
||||||
dateString.length === 10 ||
|
dateString.length === 10 ||
|
||||||
dateString.length === 7
|
dateString.length === 7 ||
|
||||||
|
dateString.length === 4
|
||||||
) {
|
) {
|
||||||
dateString += ' ';
|
dateString += ' ';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@
|
|||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>YYYY</ion-label>
|
<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>
|
||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
@ -242,10 +242,10 @@
|
|||||||
var selectedLang = "en";
|
var selectedLang = "en";
|
||||||
var customDayShortNames = document.getElementById('customMonthShortNames');
|
var customDayShortNames = document.getElementById('customMonthShortNames');
|
||||||
customDayShortNames.monthShortNames = monthShortNamesEnglish;
|
customDayShortNames.monthShortNames = monthShortNamesEnglish;
|
||||||
|
|
||||||
function toggleLanguage() {
|
function toggleLanguage() {
|
||||||
selectedLang = selectedLang === 'en' ? 'fr' : 'en';
|
selectedLang = selectedLang === 'en' ? 'fr' : 'en';
|
||||||
|
|
||||||
var customMonthShortNames = document.getElementById('customMonthShortNames');
|
var customMonthShortNames = document.getElementById('customMonthShortNames');
|
||||||
var el = document.getElementById('selectedLang');
|
var el = document.getElementById('selectedLang');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user