Options
All
  • Public
  • Public/Protected
  • All
Menu

Adaption of https://github.com/angular/components/blob/master/src/material/core/datetime/native-date-adapter.ts

  • caching of Intl objects to improve performance
  • parseDate is culture aware
  • full implementation without deriving from DateAdapter, to ensure compatibility with all angular versions.

Hierarchy

  • CustomDateAdapter

Index

Constructors

constructor

Properties

Private _clampDate

_clampDate: boolean

Whether to clamp the date between 1 and 9999 to avoid IE and Edge errors.

Protected _localeChanges

_localeChanges: Subject<void> = new Subject<void>()

Private intl

(injected) the IntlAdapterService; make sure to add this to your global providers in the app or core module.

Protected locale

locale: any

The locale to use for all dates.

Accessors

localeChanges

  • get localeChanges(): Observable<void>

Methods

Private _2digit

  • _2digit(n: number): string

Private _createDateWithOverflow

  • _createDateWithOverflow(year: number, month: number, date: number): Date

Private _format

  • _format(options: DateTimeFormatOptions, date: Date): string
  • When converting Date object to string, javascript built-in functions may return wrong results because it applies its internal DST rules. The DST rules around the world change very frequently, and the current valid rule is not always valid in previous years though. We work around this problem building a new Date object which has its internal UTC representation with the local date and time.

    Parameters

    • options: DateTimeFormatOptions
    • date: Date

      Date from which we want to get the string representation according to dtf

    Returns string

    A Date object with its UTC representation based on the passed in date info

Private _stripDirectionalityCharacters

  • _stripDirectionalityCharacters(str: string): string
  • Strip out unicode LTR and RTL characters. Edge and IE insert these into formatted dates while other browsers do not. We remove them to make output consistent and because they interfere with date parsing.

    Parameters

    • str: string

      The string to strip direction characters from.

    Returns string

    The stripped string.

addCalendarDays

  • addCalendarDays(date: Date, days: number): Date

addCalendarMonths

  • addCalendarMonths(date: Date, months: number): Date

addCalendarYears

  • addCalendarYears(date: Date, years: number): Date

clampDate

  • clampDate(date: Date, min?: Date | null, max?: Date | null): Date
  • Clamp the given date between min and max dates.

    Parameters

    • date: Date

      The date to clamp.

    • Optional min: Date | null

      The minimum value to allow. If null or omitted no min is enforced.

    • Optional max: Date | null

      The maximum value to allow. If null or omitted no max is enforced.

    Returns Date

    min if date is less than min, max if date is greater than max, otherwise date.

clone

  • clone(date: Date): Date

compareDate

  • compareDate(first: Date, second: Date): number
  • Compares two dates.

    Parameters

    • first: Date

      The first date to compare.

    • second: Date

      The second date to compare.

    Returns number

    0 if the dates are equal, a number less than 0 if the first date is earlier, a number greater than 0 if the first date is later.

createDate

  • createDate(year: number, month: number, date: number): Date

deserialize

  • deserialize(value: any): Date | null

format

  • format(date: Date, displayFormat: DateTimeFormatOptions): string

getDate

  • getDate(date: Date): number

getDateNames

  • getDateNames(): string[]

getDayOfWeek

  • getDayOfWeek(date: Date): number

getDayOfWeekNames

  • getDayOfWeekNames(style: "long" | "short" | "narrow"): string[]

getFirstDayOfWeek

  • getFirstDayOfWeek(): number

getMonth

  • getMonth(date: Date): number

getMonthNames

  • getMonthNames(style: "long" | "short" | "narrow"): string[]

getNumDaysInMonth

  • getNumDaysInMonth(date: Date): number

getYear

  • getYear(date: Date): number

getYearName

  • getYearName(date: Date): string

invalid

  • invalid(): Date

isDateInstance

  • isDateInstance(obj: any): boolean

isValid

  • isValid(date: Date): boolean

parse

  • parse(value: any): Date | null

sameDate

  • sameDate(first: Date | null, second: Date | null): boolean

setLocale

  • setLocale(locale: any): void

toIso8601

  • toIso8601(date: Date): string

today

  • today(): Date

Generated using TypeDoc