(
config: {
locale: string
timeZone?: string
formats: CustomFormats
onError: OnErrorFn
},
getDateTimeFormat: Formatters['getDateTimeFormat'],
from: Parameters<IntlFormatters['formatDateTimeRange']>[0],
to: Parameters<IntlFormatters['formatDateTimeRange']>[1],
options: Parameters<IntlFormatters['formatDateTimeRange']>[2] = {}
)
| 123 | } |
| 124 | |
| 125 | export function formatDateTimeRange( |
| 126 | config: { |
| 127 | locale: string |
| 128 | timeZone?: string |
| 129 | formats: CustomFormats |
| 130 | onError: OnErrorFn |
| 131 | }, |
| 132 | getDateTimeFormat: Formatters['getDateTimeFormat'], |
| 133 | from: Parameters<IntlFormatters['formatDateTimeRange']>[0], |
| 134 | to: Parameters<IntlFormatters['formatDateTimeRange']>[1], |
| 135 | options: Parameters<IntlFormatters['formatDateTimeRange']>[2] = {} |
| 136 | ): string { |
| 137 | const fromDate = typeof from === 'string' ? new Date(from || 0) : from |
| 138 | const toDate = typeof to === 'string' ? new Date(to || 0) : to |
| 139 | |
| 140 | try { |
| 141 | return getFormatter( |
| 142 | config, |
| 143 | 'dateTimeRange', |
| 144 | getDateTimeFormat, |
| 145 | options |
| 146 | ).formatRange(fromDate, toDate) |
| 147 | } catch (e) { |
| 148 | config.onError( |
| 149 | new IntlFormatError('Error formatting date time range.', config.locale, e) |
| 150 | ) |
| 151 | } |
| 152 | |
| 153 | return String(fromDate) |
| 154 | } |
| 155 | |
| 156 | export function formatDateToParts( |
| 157 | config: { |
nothing calls this directly
no test coverage detected