@rvoh/dream
    Preparing search index...

    Class CalendarDate

    CalendarDate represents a date without time or timezone information.

    Index

    Constructors

    Properties

    dateTime: DateTime

    Accessors

    • get month(): number

      Gets the month (1-12).

      Returns number

      The month number (1 = January, 12 = December)

      CalendarDate.fromISO('2026-02-07').month  // 2
      
    • get weekdayName(): WeekdayName

      Returns the lowercase name of the weekday.

      Returns WeekdayName

      Weekday name: 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', or 'sunday'

      CalendarDate.fromISO('2026-02-09').weekdayName  // 'monday' (Feb 9, 2026 is a Monday)
      CalendarDate.fromISO('2026-02-07').weekdayName // 'saturday'

    Methods

    • Returns the difference between this CalendarDate and another in the specified unit(s).

      Type Parameters

      Parameters

      • other: CalendarDate

        CalendarDate to compare against

      • Optionalunit: U

        Unit or units to return (years, quarters, months, weeks, days)

      Returns CalendarDateDiffResult<U>

      Object with only the specified units (or all units if not specified)

      const d1 = CalendarDate.fromISO('2026-02-15')
      const d2 = CalendarDate.fromISO('2026-02-07')
      d1.diff(d2, 'days') // { days: 8 }
      d1.diff(d2, ['months', 'days']) // { months: 0, days: 8 }
      d1.diff(d2) // { years: 0, months: 0, days: 8 }
    • Returns the difference between this CalendarDate and today in the specified unit(s).

      Type Parameters

      Parameters

      • Optionalunit: U

        Unit or units to return (years, quarters, months, weeks, days)

      Returns CalendarDateDiffResult<U>

      Object with only the specified units (or all units if not specified)

      const future = CalendarDate.today().plus({ days: 5 })
      future.diffNow('days') // { days: 5 }
      future.diffNow(['months', 'days']) // { months: 0, days: 5 }
    • Returns a new CalendarDate at the end of the given period.

      Parameters

      • period: CalendarDateUnit

        Unit to extend to end of ('year', 'quarter', 'month', 'week', or 'day')

      Returns CalendarDate

      A CalendarDate at the end of the period

      CalendarDate.fromISO('2026-02-15').endOf('month')  // 2026-02-28
      CalendarDate.fromISO('2026-02-15').endOf('year') // 2026-12-31
    • Returns true if this CalendarDate equals another CalendarDate.

      Parameters

      Returns boolean

      true if dates are equal

      const d1 = CalendarDate.fromISO('2026-02-07')
      const d2 = CalendarDate.fromISO('2026-02-07')
      d1.equals(d2) // true
    • Returns true if this and other are in the same unit of time.

      Parameters

      • otherCalendarDate: CalendarDate

        CalendarDate to compare against

      • period: CalendarDateUnit

        Unit to check ('year', 'quarter', 'month', 'week', or 'day')

      Returns boolean

      true if same period

      const d1 = CalendarDate.fromISO('2026-02-07')
      const d2 = CalendarDate.fromISO('2026-02-15')
      d1.hasSame(d2, 'month') // true
      d1.hasSame(d2, 'day') // false
    • Returns a new CalendarDate with the given duration subtracted.

      Parameters

      • duration: CalendarDateDurationLike

        Duration to subtract (object with years, months, weeks, days, etc.)

      Returns CalendarDate

      A new CalendarDate

      CalendarDate.fromISO('2026-02-07').minus({ days: 5 })    // 2026-02-02
      CalendarDate.fromISO('2026-02-07').minus({ months: 2 }) // 2025-12-07
    • Returns a new CalendarDate with the given duration added.

      Parameters

      • duration: CalendarDateDurationLike

        Duration to add (object with years, months, weeks, days, etc.)

      Returns CalendarDate

      A new CalendarDate

      CalendarDate.fromISO('2026-02-07').plus({ days: 5 })    // 2026-02-12
      CalendarDate.fromISO('2026-02-07').plus({ months: 2 }) // 2026-04-07
    • Returns a new CalendarDate at the start of the given period.

      Parameters

      • period: CalendarDateUnit

        Unit to truncate to ('year', 'quarter', 'month', 'week', or 'day')

      Returns CalendarDate

      A CalendarDate at the start of the period

      CalendarDate.fromISO('2026-02-15').startOf('month')  // 2026-02-01
      CalendarDate.fromISO('2026-02-15').startOf('year') // 2026-01-01
    • Returns the date as an ISO 8601 string.

      Returns string

      ISO date string (e.g., '2026-02-07')

      CalendarDate.fromObject({ year: 2026, month: 2, day: 7 }).toISO()  // '2026-02-07'
      
    • Returns the date as an ISO date string. Alias for toISO().

      Returns string

      ISO date string (e.g., '2026-02-07')

      CalendarDate.fromObject({ year: 2026, month: 2, day: 7 }).toISODate()  // '2026-02-07'
      
    • Returns a JavaScript Date for this date (at midnight UTC).

      Returns Date

      A JavaScript Date instance

      const jsDate = CalendarDate.today().toJSDate()
      
    • Returns the date as an ISO string for JSON serialization.

      Returns string

      ISO date string (e.g., '2026-02-07')

      JSON.stringify({ date: CalendarDate.today() })
      
    • Returns a localized string representation of the date.

      Parameters

      • OptionalformatOpts: DateTimeFormatOptions

        Intl.DateTimeFormat options for formatting

      • Optionalopts: LocaleOptions

        Optional locale options

      Returns string

      Localized date string

      CalendarDate.today().toLocaleString()
      CalendarDate.today().toLocaleString({ month: 'long', day: 'numeric', year: 'numeric' })
    • Returns the date as an ISO string (same as toISO).

      Returns string

      ISO date string (e.g., '2026-02-07')

      String(CalendarDate.today())
      
    • Create a CalendarDate from a custom format string. Uses Luxon format tokens (e.g., 'MM/dd/yyyy', 'MMMM dd, yyyy').

      Parameters

      • text: string

        The string to parse

      • format: string

        Format string using Luxon tokens

      • Optionalopts: DateTimeOptions

      Returns CalendarDate

      A CalendarDate for the parsed date

      When the string doesn't match the format or is invalid

      CalendarDate.fromFormat('12/15/2017', 'MM/dd/yyyy')
      CalendarDate.fromFormat('May 25, 1982', 'MMMM dd, yyyy')
      CalendarDate.fromFormat('mai 25, 1982', 'MMMM dd, yyyy', { locale: 'fr' })
    • Create a CalendarDate from an ISO 8601 date string.

      Parameters

      • str: string

        ISO date string (e.g., '2026-02-07')

      • opts: { zone?: string | Zone } = {}

      Returns CalendarDate

      A CalendarDate for the given date

      When the ISO string is invalid

      CalendarDate.fromISO('2026-02-07')
      
    • Create a CalendarDate from a JavaScript Date.

      Parameters

      • javascriptDate: Date

        A JavaScript Date instance

      • opts: { zone?: string | Zone } = {}

      Returns CalendarDate

      A CalendarDate for the date portion

      CalendarDate.fromJSDate(new Date())
      CalendarDate.fromJSDate(new Date(), { zone: 'America/New_York' })
    • Create a CalendarDate from an SQL date string.

      Parameters

      • str: string

        SQL date string (e.g., '2026-02-07')

      Returns CalendarDate

      A CalendarDate for the given date

      When the SQL string is invalid

      CalendarDate.fromSQL('2026-02-07')
      
    • Returns a CalendarDate for today's date.

      Parameters

      • Optionalopts: { zone?: string | Zone }

      Returns CalendarDate

      A CalendarDate for today

      CalendarDate.today()
      CalendarDate.today({ zone: 'America/New_York' })
    • Returns a CalendarDate for tomorrow's date.

      Parameters

      • options: { zone?: string | Zone } = {}

        Optional zone (defaults to UTC)

      Returns CalendarDate

      A CalendarDate for tomorrow

      CalendarDate.tomorrow()
      CalendarDate.tomorrow({ zone: 'America/New_York' })
    • Returns a CalendarDate for yesterday's date.

      Parameters

      • options: { zone?: string | Zone } = {}

        Optional zone (defaults to UTC)

      Returns CalendarDate

      A CalendarDate for yesterday

      CalendarDate.yesterday()
      CalendarDate.yesterday({ zone: 'America/New_York' })