MCPcopy Index your code
hub / github.com/formatjs/formatjs / formatDateTimeRange

Function formatDateTimeRange

packages/intl/dateTime.ts:125–154  ·  view source on GitHub ↗
(
  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] = {}
)

Source from the content-addressed store, hash-verified

123}
124
125export 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
156export function formatDateToParts(
157 config: {

Callers

nothing calls this directly

Calls 2

getFormatterFunction · 0.70
formatRangeMethod · 0.65

Tested by

no test coverage detected