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

Function dateGetter

packages/common/src/i18n/format_date.ts:318–342  ·  view source on GitHub ↗

* Returns a date formatter that transforms a date into its locale digit representation

(
  name: DateType,
  size: number,
  offset: number = 0,
  trim = false,
  negWrap = false,
)

Source from the content-addressed store, hash-verified

316 * Returns a date formatter that transforms a date into its locale digit representation
317 */
318function dateGetter(
319 name: DateType,
320 size: number,
321 offset: number = 0,
322 trim = false,
323 negWrap = false,
324): DateFormatter {
325 return function (date: Date, locale: string): string {
326 let part = getDatePart(name, date);
327 if (offset > 0 || part > -offset) {
328 part += offset;
329 }
330
331 if (name === DateType.Hours) {
332 if (part === 0 && offset === -12) {
333 part = 12;
334 }
335 } else if (name === DateType.FractionalSeconds) {
336 return formatFractionalSeconds(part, size);
337 }
338
339 const localeMinus = getLocaleNumberSymbol(locale, NumberSymbol.MinusSign);
340 return padNumber(part, size, localeMinus, trim, negWrap);
341 };
342}
343
344function getDatePart(part: DateType, date: Date): number {
345 switch (part) {

Callers 1

getDateFormatterFunction · 0.85

Calls 4

getLocaleNumberSymbolFunction · 0.90
getDatePartFunction · 0.85
formatFractionalSecondsFunction · 0.85
padNumberFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…