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

Function getDatePart

packages/common/src/i18n/format_date.ts:344–368  ·  view source on GitHub ↗
(part: DateType, date: Date)

Source from the content-addressed store, hash-verified

342}
343
344function getDatePart(part: DateType, date: Date): number {
345 switch (part) {
346 case DateType.FullYear:
347 return date.getFullYear();
348 case DateType.Month:
349 return date.getMonth();
350 case DateType.Date:
351 return date.getDate();
352 case DateType.Hours:
353 return date.getHours();
354 case DateType.Minutes:
355 return date.getMinutes();
356 case DateType.Seconds:
357 return date.getSeconds();
358 case DateType.FractionalSeconds:
359 return date.getMilliseconds();
360 case DateType.Day:
361 return date.getDay();
362 default:
363 throw new RuntimeError(
364 RuntimeErrorCode.UNKNOWN_DATE_TYPE_VALUE,
365 ngDevMode && `Unknown DateType value "${part}".`,
366 );
367 }
368}
369
370/**
371 * Returns a date formatter that transforms a date into its locale string representation

Callers 1

dateGetterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…