Class DateValue

Date of a chess game. It can be either partially defined (with the year only, or with the year and month but without day of month), or fully defined (with year, month and day of month).

See

date

Hierarchy

  • DateValue

Constructors

  • Parameters

    • year: number
    • Optional month: number

      If provided, must be between 1 (January) and 12 (December) inclusive.

    • Optional day: number

      If provided, must be between 1 and the number of days in the corresponding month (thus 31 at most).

    Returns DateValue

  • Construct a DateValue object from a standard JavaScript Date object.

    With this constructor, the type of the returned object is always 'ymd' (see type).

    Parameters

    • date: Date

    Returns DateValue

Methods

  • Day in month, valued between 1 and the number of days in the corresponding month (thus 31 at most).

    Throws

    IllegalArgument if the current type is 'y' or 'ym' (see type).

    Returns number

  • Month index, valued between 1 (January) and 12 (December) inclusive.

    Throws

    IllegalArgument if the current type is 'y' (see type).

    Returns number

  • Convert the current object into a standard JavaScript Date object.

    If the type of the current object is 'ym', the returned Date object points at the first day of the corresponding month. If the type of the current object is 'y', the returned Date object points at the first day of the corresponding year.

    Returns Date

  • Get the date of the game as a human-readable string (e.g. 'November 1955', 'September 4, 2021').

    Parameters

    • Optional locales: string | string[]

      Locales to use to generate the result. If undefined, the default locale of the execution environment is used. See Intl documentation for more details.

    Returns string

  • Get the date in a PGN format (e.g. '2022.07.19', '2022.07.??' or '2022.??.??' depending on the type of the current object).

    Returns string

  • Get the date in a compact format (e.g. '2022-07-19', '2022-07-**' or '2022-**-**' depending on the type of the current object).

    Returns string

  • Type of date value:

    • 'y' means that only the year is defined,
    • 'ym' means that the year and the month are defined, but not the day in month,
    • 'ymd' means that the exact day is defined.

    Returns "y" | "ym" | "ymd"

  • Year (e.g. 2022).

    Returns number

  • Whether the given year/month/day would corresponds to a valid date or not.

    Parameters

    • year: number
    • Optional month: number
    • Optional day: number

    Returns boolean

Generated using TypeDoc