@haxall/haxall
    Preparing search index...

    Class Date

    Date represents a day in time independent of a timezone.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Compare based on year, month, and day.

      Parameters

      Returns number

    • Get the day of the month as a number between 1 and 31.

      Returns number

    • Return the day of the year as a number between 1 and 365 (or 1 to 366 if a leap year).

      Returns number

    • Two dates are equal if they have the same year, month, and day.

      Parameters

      Returns boolean

    • Get the first day of this Date's current month.

      Example:

      Date("2009-10-28").firstOfMonth  =>  2009-10-01
      

      Returns Date

    • Get the beginning of this date's three month quarter

      Example:

      Date("2025-04-28").firstOfQuarter  =>  2025-04-01
      

      Returns Date

    • Get the Jan 1st of this Date's current year.

      Example:

      Date("2025-10-28").firstOfYear  =>  2025-01-01
      

      Returns Date

    • Return hash of year, month, and day.

      Returns number

    • Convenience for this > that

      Parameters

      Returns boolean

    • Convenience for this < that

      Parameters

      Returns boolean

    • Return if this Obj is immutable and safe to share between threads:

      • an instance of a const class
      • the result of toImmutable on List, Map, or Buf
      • a Func object may or may not be immutable - see sys::Func.
      • other instances are assumed mutable and return false

      Returns boolean

    • Return if this date is in the same year and month of that

      Parameters

      Returns boolean

    • Return if this date is in the same year of that

      Parameters

      Returns boolean

    • Return is this date equal to today.

      Returns boolean

    • Return is this date equal to today + 1day.

      Returns boolean

    • Return is this date equal to today - 1day.

      Returns boolean

    • Get the last day of this Date's current month.

      Example:

      Date("2009-10-28").lastOfMonth  =>  2009-10-31
      

      Returns Date

    • Get the end of this date's three month quarter

      Example:

      Date("2025-04-28").lastOfQuarter  =>  2025-06-30
      

      Returns Date

    • Get the Dec 31st of this Date's current year.

      Example:

      Date("2025-10-28").lastOfYear  =>  2025-12-31
      

      Returns Date

    • Return a DateTime for the beginning of this day at midnight.

      Parameters

      Returns DateTime

    • Subtract the specified number of days to this date to get a date in the past. Throw ArgErr if days parameter is not a whole number of days (must be evenly divisible by 24hr).

      Example:

      Date(2008, Month.feb, 28) - 2day  =>  2008-02-26
      

      Parameters

      Returns Date

    • Return the delta between this and the given date. The result is always an exact multiple of 24 hour days.

      Example:

      Date(2009, Month.jan, 5) - Date(2009, Month.jan, 2)  =>  3day
      

      Parameters

      Returns Duration

    • Get the month of this date.

      Returns Month

    • Add the specified number of days to this date to get a date in the future. Throw ArgErr if days parameter is not a whole number of days (must be evenly divisible by 24hr).

      Example:

      Date(2008, Month.feb, 28) + 2day  =>  2008-03-01
      

      Parameters

      Returns Date

    • Integer between 1 and 4 for which of the three month quarters this date falls in.

      Returns number

    • Get this Date as a Fantom expression suitable for code generation.

      Returns string

    • Combine this Date with the given Time to return a DateTime.

      Parameters

      Returns DateTime

    • Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:

      • if type is const, return this
      • if already an immutable List, Map, Buf, or Func return this
      • if a List, then attempt to perform a deep clone by calling toImmutable on all items
      • if a Map, then attempt to perform a deep clone by calling toImmutable on all values (keys are already immutable)
      • some Funcs can be made immutable - see sys::Func
      • if a Buf create immutable copy, see sys::Buf
      • any other object throws NotImmutableErr

      Returns Readonly<this>

    • Format this instance according to ISO 8601 using the pattern:

      YYYY-MM-DD
      

      Also see fromIso and toStr.

      Returns string

    • Format this date according to the specified pattern. If pattern is null, then a localized default is used. The pattern format is the same as DateTime.toLocale:

      YY     Two digit year             07
      YYYY Four digit year 2007
      M One/two digit month 6, 11
      MM Two digit month 06, 11
      MMM Three letter abbr month Jun, Nov
      MMMM Full month June, November
      D One/two digit day 5, 28
      DD Two digit day 05, 28
      DDD Day with suffix 1st, 2nd, 3rd, 24th
      WWW Three letter abbr weekday Tue
      WWWW Full weekday Tuesday
      Q Quarter number 3
      QQQ Quarter with suffix 3rd
      QQQQ Quarter spelled out 3rd Quarter
      'xyz' Literal characters

      Parameters

      • Optionalpattern: string
      • Optionallocale: Locale

      Returns string

    • Return programmatic ISO 8601 string encoding formatted as follows:

      YYYY-MM-DD
      2009-01-10

      Also fromStr, toIso, and toLocale.

      Returns string

    • Trap a dynamic call for handling. Dynamic calls are invoked with the -> shortcut operator:

      a->x        a.trap("x", null)
      a->x() a.trap("x", null)
      a->x = b a.trap("x", [b])
      a->x(b) a.trap("x", [b])
      a->x(b, c) a.trap("x", [b, c])

      The default implementation provided by Obj attempts to use reflection. If name maps to a method, it is invoked with the specified arguments. If name maps to a field and args.size is zero, get the field. If name maps to a field and args.size is one, set the field and return args[0]. Otherwise throw UnknownSlotErr.

      Parameters

      Returns JsObj

    • Get the Type instance which represents this object's class. Also seeType.of or Pod.of.

      Returns Type

    • Get the day of the week for this date.

      Returns Weekday

    • Return the week number of the year as a number between 1 and 53 using the given weekday as the start of the week (defaults to current locale).

      Parameters

      Returns number

    • This method called whenever an it-block is applied to an object. The default implementation calls the function with this, and then returns this.

      Parameters

      • f: (arg0: this) => void

      Returns this

    • Get the year as a number such as 2009.

      Returns number

    • Default value is "2000-01-01".

      Returns Date

    • Write x.toStr to standard output followed by newline. If x is null then print "null". If no argument is provided then print an empty line.

      Parameters

      Returns void

    • Parse an ISO 8601 date. If invalid format and checked is false return null, otherwise throw ParseErr. The following format is supported:

      YYYY-MM-DD
      

      Also see toIso and fromStr.

      Parameters

      • s: string
      • Optionalchecked: boolean

      Returns Date

    • Parse a string into a Date using the given pattern. If string is not a valid format then return null or raise ParseErr based on checked flag. See toLocale for pattern syntax.

      Parameters

      • str: string
      • pattern: string
      • Optionalchecked: boolean

      Returns Date

    • Parse the string into a Date from the programmatic encoding defined by toStr. If the string cannot be parsed into a valid Date and checked is false then return null, otherwise throw ParseErr.

      Parameters

      • s: string
      • Optionalchecked: boolean
      • ...args: unknown[]

      Returns Date

    • Make for the specified date values:

      • year: no restriction (although only 1901-2099 maps to DateTime)
      • month: Month enumeration
      • day: 1-31

      Throw ArgErr if any of the parameters are out of range.

      Parameters

      • year: number
      • month: Month
      • day: number
      • ...args: unknown[]

      Returns Date

    • Get today's Date using specified timezone.

      Parameters

      Returns Date

    • Get tomorrow's Date using specified timezone.

      Parameters

      Returns Date

    • Get yesterday's Date using specified timezone.

      Parameters

      Returns Date