MCPcopy Create free account
hub / github.com/angular/angular / getDatePart

Function getDatePart

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

Source from the content-addressed store, hash-verified

343}
344
345function getDatePart(part: DateType, date: Date): number {
346 switch (part) {
347 case DateType.FullYear:
348 return date.getFullYear();
349 case DateType.Month:
350 return date.getMonth();
351 case DateType.Date:
352 return date.getDate();
353 case DateType.Hours:
354 return date.getHours();
355 case DateType.Minutes:
356 return date.getMinutes();
357 case DateType.Seconds:
358 return date.getSeconds();
359 case DateType.FractionalSeconds:
360 return date.getMilliseconds();
361 case DateType.Day:
362 return date.getDay();
363 default:
364 throw new RuntimeError(
365 RuntimeErrorCode.UNKNOWN_DATE_TYPE_VALUE,
366 ngDevMode && `Unknown DateType value "${part}".`,
367 );
368 }
369}
370
371/**
372 * 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