Class Date

Additional static members for the native Date class.

Does not extend the native Date class.

Constructors

Properties

DAY_NAMES: string[] = ...

The list of full day names in English.

MONTH_NAMES: string[] = ...

The list of full month names in English.

Methods

  • Return whether two dates occur on the same 24-hour day.

    That is, if both dates have the same year, same month, and same day (date of the month).

    Parameters

    • date1: Date

      the first date

    • date2: Date

      the second date

    Returns boolean

    does 'YYYY-MM-DD' of date1 equal 'YYYY-MM-DD' of date2?

  • Return the percentage of the day that has passed at the given time.

    For example:

    • 00:00 => 0.00
    • 06:00 => 0.25
    • 12:00 => 0.50
    • 18:00 => 0.75

    Parameters

    • date: Date

      a Date object

    Returns number

    the proportion