Skip to content

fix(@formatjs/intl-datetimeformat): add synthetic range, fix #4535#5682

Closed
longlho wants to merge 1 commit intomainfrom
12-25-fix_formatjs_intl-datetimeformat_add_synthetic_range_fix_4535
Closed

fix(@formatjs/intl-datetimeformat): add synthetic range, fix #4535#5682
longlho wants to merge 1 commit intomainfrom
12-25-fix_formatjs_intl-datetimeformat_add_synthetic_range_fix_4535

Conversation

@longlho
Copy link
Member

@longlho longlho commented Dec 26, 2025

TL;DR

Fixed date range formatting to avoid duplicating dates when formatting time ranges on the same day.

What changed?

  • Enhanced the date extraction script to properly handle interval formats according to the TR35 specification
  • Added support for synthesizing interval formats for combined date+time skeletons
  • Implemented logic to use time interval patterns with date patterns when formatting ranges on the same day
  • Added test case for issue Weird behavior of FormattedDateTimeRange in React Native #4535 to verify the fix works correctly

How to test?

Run the new test case that verifies a date range on the same day with different times:

const dtf = new DateTimeFormat('en-GB', {
  weekday: 'short',
  year: 'numeric',
  month: 'short',
  day: 'numeric',
  hour: 'numeric',
  minute: 'numeric',
});

// Same day (Sept 22, 2024), different times (14:00 to 16:00)
const result = dtf.formatRange(
  new Date('2024-09-22T14:00:00'),
  new Date('2024-09-22T16:00:00')
);

// Should output: "Sun, 22 Sept 2024, 14:00–16:00" (date appears only once)

Why make this change?

Fixes issue #4535 where date ranges on the same day would incorrectly duplicate the date information. This improves readability by following the CLDR standard for interval formatting, which specifies that when formatting a time range on the same day, the date should only appear once. The implementation now correctly follows the TR35 specification for interval formats.

@longlho longlho marked this pull request as ready for review December 26, 2025 02:44
Copy link
Member Author

longlho commented Dec 26, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • main - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@graphite-app
Copy link

graphite-app bot commented Dec 26, 2025

Merge activity

  • Dec 26, 2:48 AM UTC: longlho added this pull request to the Graphite merge queue.
  • Dec 26, 2:48 AM UTC: CI is running for this pull request on a draft pull request (#5683) due to your merge queue CI optimization settings.
  • Dec 26, 2:51 AM UTC: Merged by the Graphite merge queue via draft PR: #5683.

graphite-app bot pushed a commit that referenced this pull request Dec 26, 2025
…5682)

### TL;DR

Fixed date range formatting to avoid duplicating dates when formatting time ranges on the same day.

### What changed?

- Enhanced the date extraction script to properly handle interval formats according to the TR35 specification
- Added support for synthesizing interval formats for combined date+time skeletons
- Implemented logic to use time interval patterns with date patterns when formatting ranges on the same day
- Added test case for issue #4535 to verify the fix works correctly

### How to test?

Run the new test case that verifies a date range on the same day with different times:

```javascript
const dtf = new DateTimeFormat('en-GB', {
  weekday: 'short',
  year: 'numeric',
  month: 'short',
  day: 'numeric',
  hour: 'numeric',
  minute: 'numeric',
});

// Same day (Sept 22, 2024), different times (14:00 to 16:00)
const result = dtf.formatRange(
  new Date('2024-09-22T14:00:00'),
  new Date('2024-09-22T16:00:00')
);

// Should output: "Sun, 22 Sept 2024, 14:00–16:00" (date appears only once)
```

### Why make this change?

Fixes issue #4535 where date ranges on the same day would incorrectly duplicate the date information. This improves readability by following the CLDR standard for interval formatting, which specifies that when formatting a time range on the same day, the date should only appear once. The implementation now correctly follows the TR35 specification for interval formats.
@graphite-app graphite-app bot closed this Dec 26, 2025
@graphite-app graphite-app bot deleted the 12-25-fix_formatjs_intl-datetimeformat_add_synthetic_range_fix_4535 branch December 26, 2025 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant