Class IntlDate

Creates a date tied to a given locale (default system locale) which can be formatted in that locale's language using the native Intl Apis directly or using a formatting string.

See

Intl Apis

Hierarchy

  • IntlDate

Constructors

  • Creates a new IntlDate in local time and specified locale (default is system locale). Note: The allowed values for month start at 1, which is different from legacy Date

    Returns

    Parameters

    • Optional obj: DateLike

      The date value (default is current local time)

    • opts: any = {}

      The options for this date

    Returns IntlDate

Properties

intlRelativeFormat: RelativeTimeFormat
locale?: string

Accessors

  • get dayOfWeek(): number
  • Returns the weekday as a number between 1 and 7, inclusive, where Monday is 1 and Sunday is 7.

    Returns number

  • get month(): number
  • Get the this date's month as a number from 1 to 12, inclusive.

    Returns number

Methods

  • Returns a localized string representation of this date, according to the given format string. Format codes use the same specification as moment.

    See

    List of formats

    Example

    new IntlDate().format('MM/DD/YYYY') // '10/31/2022'
    

    Parameters

    • str: string

      The format string to use

    Returns string

  • Parameters

    • unit: RelativeTimeFormatUnit = 'seconds'

    Returns string

  • Returns the number of milliseconds since the Unix Epoch (January 1, 1970 UTC)

    Returns number

  • Check if this date is after another date. The other value will be parsed as an IntlDate if not already so.

    Returns

    Returns true if this date is after the given value

    Parameters

    • other: DateLike

      Another date or date like object

    Returns boolean

  • Check if this date is before another date. The other value will be parsed as an IntlDate if not already so.

    Returns

    Returns true if this date is before the given value

    Parameters

    • other: DateLike

      Another date or date like object

    Returns boolean

  • Check if this date is strictly after the given start and before stop dates. The values will be parsed as an IntlDate if not already so.

    Returns

    Returns true if this date is greater than start and less than stop.

    Parameters

    Returns boolean

  • Check if this date is the same as other.

    Returns

    Returns true if this date is the same as other

    Parameters

    • other: Date | IntlDate

      Another date object

    Returns boolean

  • Gets the number of weeks in the current year, according to ISO weeks.

    Returns number

  • Parameters

    • n: number
    • unit: RelativeTimeFormatUnit = 'seconds'

    Returns string

  • Returns the number of seconds since the Unix Epoch (January 1, 1970 UTC).

    See

    Example

    new IntlDate().timestamp() // 1318874398
    

    Returns number

  • Returns a new copy of the native Date object used by this instance.

    Returns

    A new Date object

    Returns Date

  • Returns the date part formatted as ISO8601.

    Example

    new IntlDate().toISODate() // '2022-10-31'
    

    Returns string

  • Formats a string to the ISO8601 standard.

    Example

    new IntlDate().toISOString() // '2022-10-31T22:44:30.652Z'
    

    Returns string

  • Returns the time part formatted as ISO8601.

    Example

    new IntlDate().toISOTime() // 'T22:44:30.652Z'
    

    Returns string

  • Parameters

    • unit: RelativeTimeFormatUnit = 'seconds'

    Returns string

  • Returns an object containing year, month, day-of-month, hours, minutes, seconds, milliseconds.

    Returns

    An object like {year, month, date, hours, minutes, seconds, ms}

    Returns DateObject

  • Returns the number of seconds since the Unix Epoch (January 1, 1970 UTC).

    See

    Example

    new IntlDate().toSeconds() // 1318874398
    

    Returns number

  • Returns a localized string representation of this date.

    See

    Intl.DateTimeFormat()

    Parameters

    • Optional opts: DateTimeFormatOptions

      The options to use for the format

    Returns string

  • Returns the difference in minutes between this date and UTC

    Returns number

  • Gets the number of weeks according to locale in the current year.

    Returns number

Generated using TypeDoc