MCPcopy
hub / github.com/valor-software/ngx-bootstrap / formatDate

Function formatDate

src/chronos/format.ts:13–30  ·  view source on GitHub ↗
(date: Date, format?: string, locale?: string, isUTC?: boolean, offset = 0)

Source from the content-addressed store, hash-verified

11import { isDateValid } from './utils/type-checks';
12
13export function formatDate(date: Date, format?: string, locale?: string, isUTC?: boolean, offset = 0): string {
14 const _locale = getLocale(locale || 'en');
15 if (!_locale) {
16 throw new Error(
17 `Locale "${locale}" is not defined, please add it with "defineLocale(...)"`
18 );
19 }
20
21 const _format = format || (isUTC ? 'YYYY-MM-DDTHH:mm:ss[Z]' : 'YYYY-MM-DDTHH:mm:ssZ');
22
23 const output = formatMoment(date, _format, _locale, isUTC, offset);
24
25 if (!output) {
26 return output;
27 }
28
29 return _locale.postformat(output);
30}
31
32// format date using native date object
33export function formatMoment(date: Date, _format: string, locale: Locale, isUTC?: boolean, offset = 0): string {

Callers 10

formatMethod · 0.90
calendarFunction · 0.90
_setInputValueMethod · 0.90
_setInputValueMethod · 0.90
formatYearsCalendarFunction · 0.90
formatYearRangeTitleFunction · 0.90
formatMonthsCalendarFunction · 0.90
formatDaysCalendarFunction · 0.90
getWeekNumbersFunction · 0.90

Calls 3

getLocaleFunction · 0.90
formatMomentFunction · 0.85
postformatMethod · 0.65

Tested by

no test coverage detected