• Overview

    A shorthand function-object for DataAPIDate. May be used anywhere when creating new DataAPIDates.

    See DataAPIDate and its methods for information about input parameters, formats, functions, etc.

    Parameters

    • Rest ...params: [string] | [Date] | [number, number, number]

    Returns DataAPIDate

    Example

    // equiv. to `new DataAPIDate('2004-09-14')`
    date('2004-09-14')

    // equiv. to `new DataAPIDate(2004, 9, 14)`
    date(2004, 9, 14)

    // equiv. to `DataAPIDate.now()`
    date.now()

Properties

now: ((this) => DataAPIDate) = DataAPIDate.now

Type declaration

    • (this): DataAPIDate
    • Overview

      Returns the current date in the local timezone.

      Equivalent to new DataAPIDate(new Date()).

      Parameters

      • this: void

      Returns DataAPIDate

      The current date in the local timezone

      Example

      const now = date.now();
      // or
      const now = DataAPIDate.now()
ofEpochDay: ((this, epochDays) => DataAPIDate) = DataAPIDate.ofEpochDay

Type declaration

    • (this, epochDays): DataAPIDate
    • Overview

      Creates a DataAPIDate from the number of days since the epoch.

      The number may be negative, but must be an integer within the range [-100_000_000, 100_000_000].

      Parameters

      • this: void
      • epochDays: number

        The number of days since the epoch (may be negative)

      Returns DataAPIDate

      The date representing the given number of days since the epoch

      Example

      DataAPIDate.ofEpochDay(0) // '1970-01-01'

      date.ofEpochDay(12675) // '2004-09-14'

      date.ofEpochDay(-1) // '1969-12-31'
ofYearDay: ((this, year, dayOfYear) => DataAPIDate) = DataAPIDate.ofYearDay

Type declaration

    • (this, year, dayOfYear): DataAPIDate
    • Overview

      Creates a DataAPIDate from a year and a valid day of the year.

      The year may be negative.

      The day-of-year must be valid for the year, otherwise an exception will be thrown.

      Parameters

      • this: void
      • year: number

        The year to use

      • dayOfYear: number

        The day of the year to use (1-indexed)

      Returns DataAPIDate

      The date representing the given year and day of the year

      Example

      DataAPIDate.ofYearDay(2004, 258) // 2004-09-14

      date.ofYearDay(2004, 1) // 2004-01-01

      date.ofYearDay(2004, 366) // 2004-12-31 (ok b/c 2004 is a leap year)
utcnow: ((this) => DataAPIDate) = DataAPIDate.utcnow

Type declaration

    • (this): DataAPIDate
    • Overview

      Returns the current date in UTC.

      Uses Date.now() under the hood.

      Parameters

      • this: void

      Returns DataAPIDate

      The current date in UTC

      Example

      const now = date.utcnow();
      // or
      const now = DataAPIDate.utcnow()