Represents a pure date (with no time component). Useful for e.g. representing dates in a timeseries.

Internally the date is stored as a JS Date object in the UTC timezone with midnight (00:00:00) as the time component.

Hierarchy

  • PureDate

Constructors

Properties

Accessors

Methods

Constructors

  • Constructs a new PureDate from a JS Date object or a YYYY-MM-DD string. Throws an exception if the provided date has a nonzero time component.

    Parameters

    • date: string | Date

      Either a JS Date object or a YYYY-MM-DD string.

    Returns PureDate

Properties

jsDate: Date

Returns a JS Date instance representing this date, with the time component set to midnight UTC.

Accessors

Methods

  • Returns the number of days between the current date and the provided other date.

    Returns

    The number of days between the current date and the provided other date.

    Parameters

    • other: PureDate

      The other date to compare against.

    Returns number

  • Checks if a Date object is valid as a PureDate (i.e. contains no time component in UTC).

    Returns

    True if the date is valid, false otherwise.

    Parameters

    • jsDate: Date

      The date to check.

    Returns boolean

Generated using TypeDoc