mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
fix(datetime): hourCycle formats hour correctly (#25869)
resolves #25862
This commit is contained in:
@ -155,4 +155,17 @@ describe('getLocalizedTime', () => {
|
|||||||
|
|
||||||
expect(getLocalizedTime('en-US', datetimeParts, false)).toEqual('9:40 AM');
|
expect(getLocalizedTime('en-US', datetimeParts, false)).toEqual('9:40 AM');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should avoid Chromium bug when using 12 hour time in a 24 hour locale', () => {
|
||||||
|
const datetimeParts = {
|
||||||
|
day: 1,
|
||||||
|
month: 1,
|
||||||
|
year: 2022,
|
||||||
|
hour: 0,
|
||||||
|
minute: 0,
|
||||||
|
tzOffset: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(getLocalizedTime('en-GB', datetimeParts, false)).toEqual('12:00 am');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -19,7 +19,11 @@ export const getLocalizedTime = (locale: string, refParts: DatetimeParts, use24H
|
|||||||
hour: 'numeric',
|
hour: 'numeric',
|
||||||
minute: 'numeric',
|
minute: 'numeric',
|
||||||
timeZone: 'UTC',
|
timeZone: 'UTC',
|
||||||
hour12: !use24Hour,
|
/**
|
||||||
|
* We use hourCycle here instead of hour12 due to:
|
||||||
|
* https://bugs.chromium.org/p/chromium/issues/detail?id=1347316&q=hour12&can=2
|
||||||
|
*/
|
||||||
|
hourCycle: use24Hour ? 'h23' : 'h12',
|
||||||
}).format(
|
}).format(
|
||||||
new Date(
|
new Date(
|
||||||
convertDataToISO({
|
convertDataToISO({
|
||||||
|
|||||||
Reference in New Issue
Block a user