Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 66e13d4

Browse files
danielkaxisTigge
authored andcommitted
fix(dateTimePicker): display midnight as 00.XX
- On some locales, hourCycle is being set to 'h24' as default if hour12 is specified. - Removes hour12 if it's false and adds 'h23'
1 parent f937474 commit 66e13d4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/core/src/DateTimePicker/DateTimeInformation.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,21 @@ export const DateTimeInformation: FC<DateTimeInformationProps> = ({
5858
<TimeIcon height={iconSize.medium} width={iconSize.medium} />
5959
<Typography variant="page-heading">
6060
{dateTime.toLocaleString(lang, {
61-
hour12,
6261
hour: 'numeric',
6362
minute: 'numeric',
63+
/**
64+
* There is an issue with displaying midnight as 0 or 24.
65+
* If hour12 is specified, even as false, it defaults
66+
* to hourCycle 'h24'. Not using hour12 if it's false and specifying h23
67+
* resolves the issue. The issue exists on chrome-based browsers.
68+
*
69+
* More information regarding the issue can be found here:
70+
* https://github.com/tc39/ecma402/pull/436
71+
*
72+
* Information regarding hourCycle can be found here:
73+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle
74+
*/
75+
...(hour12 ? { hour12 } : { hourCycle: 'h23' }),
6476
})}
6577
</Typography>
6678
</DateInfoContainer>

0 commit comments

Comments
 (0)