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

Function formatTime

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

Source from the content-addressed store, hash-verified

99}
100
101export function formatTime(
102 config: {
103 locale: string
104 timeZone?: string
105 formats: CustomFormats
106 onError: OnErrorFn
107 },
108 getDateTimeFormat: Formatters['getDateTimeFormat'],
109 value: Parameters<IntlFormatters['formatTime']>[0],
110 options: Parameters<IntlFormatters['formatTime']>[1] = {}
111): string {
112 const date = typeof value === 'string' ? new Date(value || 0) : value
113
114 try {
115 return getFormatter(config, 'time', getDateTimeFormat, options).format(date)
116 } catch (e) {
117 config.onError(
118 new IntlFormatError('Error formatting time.', config.locale, e)
119 )
120 }
121
122 return String(date)
123}
124
125export function formatDateTimeRange(
126 config: {

Callers 2

formatTime.test.tsFile · 0.90
Comp2Function · 0.85

Calls 2

getFormatterFunction · 0.70
formatMethod · 0.65

Tested by

no test coverage detected