-
Notifications
You must be signed in to change notification settings - Fork 4
Variable.formatDateTimeRangeToParts
connor-baer edited this page Nov 8, 2025
·
2 revisions
@sumup-oss/intl / formatDateTimeRangeToParts
constformatDateTimeRangeToParts: (startDate,endDate,locales?,options?) => (DateTimeFormatPart| {type:"date";value:string; })[]
Defined in: lib/date-time-format/index.ts:339
Formats a datetime range to parts with support for various date and time styles.
| Parameter | Type |
|---|---|
startDate |
FormattableDateTime |
endDate |
FormattableDateTime |
locales? |
string | string[] |
options? |
DateTimeFormatOptions |
(DateTimeFormatPart | { type: "date"; value: string; })[]
import { formatDateTimeRangeToParts } from '@sumup-oss/intl';
const startDate = new Temporal.PlainDate(2000, 2, 1);
const endDate = new Temporal.PlainDate(2000, 2, 29);
formatDateTimeRangeToParts(startDate, endDate, 'de-DE');
// [
// {
// "source": "startRange",
// "type": "day",
// "value": "01",
// },
// {
// "source": "shared",
// "type": "literal",
// "value": ".–",
// },
// {
// "source": "endRange",
// "type": "day",
// "value": "29",
// },
// {
// "source": "shared",
// "type": "literal",
// "value": ".",
// },
// {
// "source": "shared",
// "type": "month",
// "value": "02",
// },
// {
// "source": "shared",
// "type": "literal",
// "value": ".",
// },
// {
// "source": "shared",
// "type": "year",
// "value": "2000",
// },
// ]In runtimes that don't support the Intl.DateTimeFormat.formatDateTimeRangeToParts API,
the start and end dates are localized individually and joined using an en dash.