mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-24 23:01:57 +08:00

committed by
Liam DeBeasi

parent
00891119f7
commit
b7761fe353
@ -324,6 +324,19 @@ export const updateDate = (existingData: DatetimeData, newData: any): boolean =>
|
||||
(existingData as any)[key] = newData[key].value;
|
||||
}
|
||||
return true;
|
||||
} else if (newData.ampm) {
|
||||
// Even though in the picker column hour values are between 1 and 12, the hour value is actually normalized
|
||||
// to [0, 23] interval. Because of this when changing between AM and PM we have to update the hour so it points
|
||||
// to the correct HH hour
|
||||
newData.hour = {
|
||||
value: newData.hour
|
||||
? newData.hour.value
|
||||
: (newData.ampm.value === 'pm'
|
||||
? (existingData.hour! < 12 ? existingData.hour! + 12 : existingData.hour!)
|
||||
: (existingData.hour! >= 12 ? existingData.hour! - 12 : existingData.hour))
|
||||
};
|
||||
(existingData as any)['hour'] = newData['hour'].value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// eww, invalid data
|
||||
@ -378,7 +391,7 @@ export const getValueFromFormat = (date: DatetimeData, format: string) => {
|
||||
return (date.hour! < 12 ? 'am' : 'pm');
|
||||
}
|
||||
if (format === FORMAT_hh || format === FORMAT_h) {
|
||||
return (date.hour! > 12 ? date.hour! - 12 : date.hour);
|
||||
return (date.hour! > 12 ? date.hour! - 12 : (date.hour === 0 ? 12 : date.hour));
|
||||
}
|
||||
return (date as any)[convertFormatToKey(format)!];
|
||||
};
|
||||
|
Reference in New Issue
Block a user