Directive to convert and format Date values using Globalite. When the input value is a string, it will be parsed using the current locale. And the value for the form control will be a Date if the string is a valid date. When the value of the form control is a Date, it will be formatted using the current locale and the specified format and written to the input element.

An empty string or a string with only whitespace will be converted to null.

<input type="text" glbToDateTime [formControl]="formControl" />

Hierarchy

  • BaseConverterDirective<Date>
    • GlobalizeDateTimeDirective

Constructors

Properties

format: string = 'g'

The format to use when formatting the date. If not specified, the 'g' format will be used. See Globalite documentation for more information about the available formats.

injector: Injector = ...
localeService: LocaleService = ...
timeZone: undefined | string

The time zone to use when parsing and formatting the date.

If not specified, the default time zone of the browser will be used.

Note that Globalite time zone support is not working as expected but this is added for the future.

Accessors

Methods

  • Protected

    Determines if two values are equal.

    Parameters

    • v1: null | Date

      The first value.

    • v2: null | Date

      The second value.

    Returns boolean

    True if the values are equal, otherwise false.

  • Protected

    Coerces the value to the type supported by this directive

    Parameters

    Returns CoercedValue<Date>

    The coerced value. If the v is of Type T, it should be returned as is. If it's null, null is returned If it's a string, it should be converted to the type T and returned. If the conversion from string fails, undefined should be returned.

  • Protected

    Formats the value for display.

    Parameters

    • v: Date

      The value to format.

    Returns string

    The formatted value.

  • Protected

    Determines if two values are equal.

    Parameters

    • v1: Date

      The first value.

    • v2: Date

      The second value.

    Returns boolean

    True if the values are equal, otherwise false.