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

Function formatDate

packages/intl/dateTime.ts:78–99  ·  view source on GitHub ↗
(
  config: {
    locale: string
    timeZone?: string
    formats: CustomFormats
    onError: OnErrorFn
  },
  getDateTimeFormat: Formatters['getDateTimeFormat'],
  value: Parameters<IntlFormatters['formatDate']>[0],
  options: Parameters<IntlFormatters['formatDate']>[1] = {}
)

Source from the content-addressed store, hash-verified

76}
77
78export function formatDate(
79 config: {
80 locale: string
81 timeZone?: string
82 formats: CustomFormats
83 onError: OnErrorFn
84 },
85 getDateTimeFormat: Formatters['getDateTimeFormat'],
86 value: Parameters<IntlFormatters['formatDate']>[0],
87 options: Parameters<IntlFormatters['formatDate']>[1] = {}
88): string {
89 const date = typeof value === 'string' ? new Date(value || 0) : value
90 try {
91 return getFormatter(config, 'date', getDateTimeFormat, options).format(date)
92 } catch (e) {
93 config.onError(
94 new IntlFormatError('Error formatting date.', config.locale, e)
95 )
96 }
97
98 return String(date)
99}
100
101export function formatTime(
102 config: {

Callers 5

formatDate.test.tsFile · 0.90
myFunctionFunction · 0.85
myFunctionFunction · 0.85
CompFunction · 0.85
Comp2Function · 0.85

Calls 2

getFormatterFunction · 0.70
formatMethod · 0.65

Tested by

no test coverage detected