interface Intl.DateTimeFormatRangePart
unstable
Represents a part of a formatted date range produced by Intl.DateTimeFormat.formatRange().
Each part has a type and value that describes its role within the formatted string. The source property indicates whether the part comes from the start date, end date, or is shared between them.
Examples #
#
const dtf = new Intl.DateTimeFormat('en', {
dateStyle: 'long',
timeStyle: 'short'
});
const parts = dtf.formatRangeToParts(
new Date(2023, 0, 1, 12, 0),
new Date(2023, 0, 3, 15, 30)
);
console.log(parts);
// Parts might include elements like:
// { type: 'month', value: 'January', source: 'startRange' }
// { type: 'day', value: '1', source: 'startRange' }
// { type: 'literal', value: ' - ', source: 'shared' }
// { type: 'day', value: '3', source: 'endRange' }
// ...
Properties #
The type of date or time component this part represents. Possible values: 'day', 'dayPeriod', 'era', 'fractionalSecond', 'hour', 'literal', 'minute', 'month', 'relatedYear', 'second', 'timeZoneName', 'weekday', 'year', etc.