Function: formatDateRange()
ts
function formatDateRange(range, formatStr?):
| FormatDateRangeResult
| undefined;Formats a date range into { start, end } strings. 将日期区间格式化为开始/结束字符串。
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
range | | readonly [DateRangeInput, DateRangeInput] | null | undefined | undefined | A tuple of start and end dates / 开始和结束日期二元组 |
formatStr | string | 'YYYY-MM-DD' | Format string, same tokens as format() / 格式字符串,与 format() 一致 |
Returns
| FormatDateRangeResult | undefined
{ start, end } or undefined when range is incomplete / 区间不完整时返回 undefined
Example
ts
formatDateRange([new Date('2024-01-01'), new Date('2024-01-31')], 'YYYY-MM-DD')
// => { start: '2024-01-01', end: '2024-01-31' }Since
1.3.0