MCPcopy Index your code
hub / github.com/angular/angular / getNamedFormat

Function getNamedFormat

packages/common/src/i18n/format_date.ts:202–273  ·  view source on GitHub ↗
(locale: string, format: string)

Source from the content-addressed store, hash-verified

200}
201
202function getNamedFormat(locale: string, format: string): string {
203 const localeId = getLocaleId(locale);
204 NAMED_FORMATS[localeId] ??= {};
205
206 if (NAMED_FORMATS[localeId][format]) {
207 return NAMED_FORMATS[localeId][format];
208 }
209
210 let formatValue = '';
211 switch (format) {
212 case 'shortDate':
213 formatValue = getLocaleDateFormat(locale, FormatWidth.Short);
214 break;
215 case 'mediumDate':
216 formatValue = getLocaleDateFormat(locale, FormatWidth.Medium);
217 break;
218 case 'longDate':
219 formatValue = getLocaleDateFormat(locale, FormatWidth.Long);
220 break;
221 case 'fullDate':
222 formatValue = getLocaleDateFormat(locale, FormatWidth.Full);
223 break;
224 case 'shortTime':
225 formatValue = getLocaleTimeFormat(locale, FormatWidth.Short);
226 break;
227 case 'mediumTime':
228 formatValue = getLocaleTimeFormat(locale, FormatWidth.Medium);
229 break;
230 case 'longTime':
231 formatValue = getLocaleTimeFormat(locale, FormatWidth.Long);
232 break;
233 case 'fullTime':
234 formatValue = getLocaleTimeFormat(locale, FormatWidth.Full);
235 break;
236 case 'short':
237 const shortTime = getNamedFormat(locale, 'shortTime');
238 const shortDate = getNamedFormat(locale, 'shortDate');
239 formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Short), [
240 shortTime,
241 shortDate,
242 ]);
243 break;
244 case 'medium':
245 const mediumTime = getNamedFormat(locale, 'mediumTime');
246 const mediumDate = getNamedFormat(locale, 'mediumDate');
247 formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Medium), [
248 mediumTime,
249 mediumDate,
250 ]);
251 break;
252 case 'long':
253 const longTime = getNamedFormat(locale, 'longTime');
254 const longDate = getNamedFormat(locale, 'longDate');
255 formatValue = formatDateTime(getLocaleDateTimeFormat(locale, FormatWidth.Long), [
256 longTime,
257 longDate,
258 ]);
259 break;

Callers 1

formatDateFunction · 0.85

Calls 5

getLocaleIdFunction · 0.90
getLocaleDateFormatFunction · 0.90
getLocaleTimeFormatFunction · 0.90
getLocaleDateTimeFormatFunction · 0.90
formatDateTimeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…