fix: capitalize German 'Uhr' in 24-hour time format (#25403)

* fix: capitalize German 'Uhr' in 24-hour time format

- Conditionally apply toLowerCase() only for 12-hour format (AM/PM)
- Preserve proper capitalization for 24-hour format in German and other locales
- German 'Uhr' now displays correctly as 'Uhr' instead of 'uhr'

Fixes #24455

* refactor: remove code comments for clarity

* use ternary in return instead of mutable variable

* refactor: remove toLowerCase from time formatting

* addressed cubic suggestion

---------

Co-authored-by: Pallav <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-01-08 14:25:50 +00:00
1 parent 2f932f617c
commit f629b61be7
1 file changed
+16 -8
@@ -26,11 +26,15 @@ export const formatEventFromTime = ({ date, timeFormat, timeZone, language }: Ev
timeZone,
timeStyle: "short",
hour12: timeFormat === TimeFormat.TWELVE_HOUR ? true : false,
})
.format(startDate)
.toLowerCase();
}).format(startDate);
return { date: formattedDate, time: formattedTime };
return {
date: formattedDate,
time:
timeFormat === TimeFormat.TWELVE_HOUR
? formattedTime.toLowerCase()
: formattedTime,
};
};
export const formatEventFromToTime = ({
@@ -54,11 +58,15 @@ export const formatEventFromToTime = ({
timeZone,
timeStyle: "short",
hour12: timeFormat === TimeFormat.TWELVE_HOUR ? true : false,
})
.formatRange(startDate, endDate)
.toLowerCase();
}).formatRange(startDate, endDate);
return { date: formattedDate, time: formattedTime };
return {
date: formattedDate,
time:
timeFormat === TimeFormat.TWELVE_HOUR
? formattedTime.toLowerCase()
: formattedTime,
};
};
export const FromToTime = (props: EventFromToTime) => {