Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • NativeDateAdapter
    • MaterialDateAdapter

Index

Constructors

constructor

  • Parameters

    • matDateLocale: string
    • platform: Platform

    Returns MaterialDateAdapter

Properties

Protected _localeChanges

_localeChanges: Subject<void>

Private formatter

formatter: IFormatter

Protected locale

locale: any

The locale to use for all dates.

localeChanges

localeChanges: Observable<void>

A stream that emits when the locale changes.

useUtcForDisplay

useUtcForDisplay: boolean

Whether to use timeZone: 'utc' with Intl.DateTimeFormat when formatting dates. Without this Intl.DateTimeFormat sometimes chooses the wrong timeZone, which can throw off the result. (e.g. in the en-US locale new Date(1800, 7, 14).toLocaleDateString() will produce '8/13/1800'.

TODO(mmalerba): drop this variable. It's not being used in the code right now. We're now getting the string representation of a Date object from it's utc representation. We're keeping it here for sometime, just for precaution, in case we decide to revert some of these changes though.

Methods

addCalendarDays

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

    • date: Date
    • days: number

    Returns Date

addCalendarMonths

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

    • date: Date
    • months: number

    Returns Date

addCalendarYears

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

    • date: Date
    • years: number

    Returns 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
  • Parameters

    • date: Date

    Returns 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
  • Parameters

    • year: number
    • month: number
    • date: number

    Returns Date

deserialize

  • deserialize(value: any): Date | null
  • Returns the given value if given a valid Date or null. Deserializes valid ISO 8601 strings (https://www.ietf.org/rfc/rfc3339.txt) into valid Dates and empty string into null. Returns an invalid date for all other values.

    Parameters

    • value: any

    Returns Date | null

format

  • format(date: any, displayFormat: string): string
  • Parameters

    • date: any
    • displayFormat: string

    Returns string

getDate

  • getDate(date: Date): number
  • Parameters

    • date: Date

    Returns number

getDateNames

  • getDateNames(): string[]
  • Returns string[]

getDayOfWeek

  • getDayOfWeek(date: Date): number
  • Parameters

    • date: Date

    Returns number

getDayOfWeekNames

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

    • style: "long" | "short" | "narrow"

    Returns string[]

getFirstDayOfWeek

  • getFirstDayOfWeek(): number
  • Returns number

getFormatter

  • Returns IFormatter

getMonth

  • getMonth(date: Date): number
  • Parameters

    • date: Date

    Returns number

getMonthNames

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

    • style: "long" | "short" | "narrow"

    Returns string[]

getNumDaysInMonth

  • getNumDaysInMonth(date: Date): number
  • Parameters

    • date: Date

    Returns number

getYear

  • getYear(date: Date): number
  • Parameters

    • date: Date

    Returns number

getYearName

  • getYearName(date: Date): string
  • Parameters

    • date: Date

    Returns string

invalid

  • invalid(): Date
  • Returns Date

isDateInstance

  • isDateInstance(obj: any): boolean
  • Parameters

    • obj: any

    Returns boolean

isValid

  • isValid(date: Date): boolean
  • Parameters

    • date: Date

    Returns boolean

parse

  • parse(value: any): any
  • Parameters

    • value: any

    Returns any

sameDate

  • sameDate(first: Date | null, second: Date | null): boolean
  • Checks if two dates are equal.

    Parameters

    • first: Date | null

      The first date to check.

    • second: Date | null

      The second date to check.

    Returns boolean

    Whether the two dates are equal. Null dates are considered equal to other null dates.

setFormatter

  • Parameters

    Returns void

setLocale

  • setLocale(locale: any): void
  • Sets the locale used for all dates.

    Parameters

    • locale: any

      The new locale.

    Returns void

toIso8601

  • toIso8601(date: Date): string
  • Parameters

    • date: Date

    Returns string

today

  • today(): Date
  • Returns Date

Generated using TypeDoc