Conversation
…hour12 duplication Fixes #4535 This commit addresses two issues with FormattedDateTimeRange: 1. **H24 midnight rendering**: Same-day ranges starting at midnight (e.g., 00:00-00:45) were incorrectly showing "24:00-24:45" instead of "00:00-00:45". Root cause: The condition !rangeFormatOptions?.isDifferentDate meant "convert 0→24 when NOT in a range with different dates". Same-day ranges have isDifferentDate:false, causing unwanted conversion. Fix: Changed to !rangeFormatOptions (undefined check), so 0→24 conversion only happens in non-range single-date formatting. 2. **Date duplication with hour12**: When hour12:true, date/day were duplicated for any time range (e.g., "Wed, 18 Feb 2026, 7:00 am – Wed, 18 Feb 2026, 4:00 pm" instead of showing date once). Root cause: CLDR data synthesis fallback to alternate hour cycles (12hr ↔ 24hr) only checked if timeIntervalFormats was undefined or not an object, missing the case where it's an empty object {}. Fix: Added Object.keys().length === 0 check to properly trigger fallback when interval formats are empty, ensuring 12-hour skeletons can use 24-hour interval patterns during data generation. Co-authored-by: Long Ho <longlho@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4535
Summary
This PR fixes two bugs in
FormattedDateTimeRangethat were causing incorrect formatting:hour12: trueChanges
Bug 1: H24 Midnight Rendering
Root Cause: The condition
!rangeFormatOptions?.isDifferentDatemeant "convert 0→24 when NOT in a range with different dates". Same-day ranges haveisDifferentDate: false, causing unwanted conversion.Fix in
FormatDateTimePattern.ts:if (v === 0 && !rangeFormatOptions?.isDifferentDate)if (v === 0 && !rangeFormatOptions)Example:
Sun, 3 May 2026, 24:00–24:45Sun, 3 May 2026, 00:00–00:45✓Bug 2: Hour12 Date Duplication
Root Cause: CLDR data synthesis fallback to alternate hour cycles (12hr ↔ 24hr) only checked if
timeIntervalFormatswas undefined or not an object, missing the case where it's an empty object{}.Fix in
extract-dates.ts:Object.keys(timeIntervalFormats).length === 0checkExample:
Wed, 18 Feb 2026, 7:00 am – Wed, 18 Feb 2026, 4:00 pmWed, 18 Feb 2026, 7:00 am – 4:00 pm✓Tests
Added 3 comprehensive test cases:
Breaking Changes
None. These are bug fixes that make behavior match user expectations and LDML specifications.
Note: The fix to
extract-dates.tsrequires regenerating locale data before merging.Generated with Claude Code