@haxall/haxall
    Preparing search index...

    Class DateSpan

    DateSpan models a span of time between two dates.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    type$: Type

    Methods

    • Return a negative integer, zero, or a positive integer if this object is less than, equal to, or greater than the specified object:

      this < that   =>  <0
      this == that => 0
      this > that => >0

      This method may also be accessed via the < <= <=> >= and > shortcut operators. If not overridden the default implementation compares the toStr representations. Also see docLang.

      Examples:

      3.compare(8)  =>  -1
      8.compare(3) => 1
      8.compare(8) => 0
      3 <=> 8 => -1 // shortcut for 3.compare(8)

      Parameters

      Returns number

    • Does this span inclusively contain the given Date inclusively

      Parameters

      Returns boolean

    • Return display name for this span. If explicit is true, display actual dates, as opposed to Today or Yesterday.

      Parameters

      • Optionalexplicit: boolean

      Returns string

    • Iterate each day in this DateSpan.

      Parameters

      • func: (arg0: Date, arg1: number) => void

      Returns void

    • Iterate each month in this date range as a range of first to last day in each month.

      Parameters

      Returns void

    • Inclusive end date for this span.

      Returns Date

    • Objects are equal if start, end, and period match.

      Parameters

      Returns boolean

    • Hash is based on start/end/period.

      Returns number

    • Convenience for period == DateSpan.day

      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

    • Convenience for period == DateSpan.month

      Returns boolean

    • Convenience for period == DateSpan.quarter

      Returns boolean

    • Convenience for period == DateSpan.range

      Returns boolean

    • Convenience for period == DateSpan.week

      Returns boolean

    • Convenience for period == DateSpan.year

      Returns boolean

    • Shift start and end by the given number of days.

      Parameters

      Returns DateSpan

    • Return the next DateSpan based on the period:

      • day: next day
      • week: next week
      • month: next month
      • year: next year
      • range: roll start/end forward one day

      Returns DateSpan

    • Get number of days in this span.

      Returns number

    • The period: day, week, month, quarter, year, or range.

      Returns string

    • Shift start and end by the given number of days.

      Parameters

      Returns DateSpan

    • Return the previous DateSpan based on the period:

      • day: previous day
      • week: previous week
      • month: previous month
      • quarter: previous quarter
      • year: previous year
      • range: roll start/end back one day

      Returns DateSpan

    • Start date for this span.

      Returns Date

    • Return axon representation for this span.

      Returns string

    • 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>

    • Convert this instance to a Span instance

      Parameters

      Returns Span

    • Str representation is ",<end|period>".

      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

    • 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

    • Constant for a day period.

      Returns string

    • 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

    • Construct DateSpan from Str. This method supports parsing from the following formats:

      • ","
      • ","
      • "today", "yesterday"
      • "thisWeek", "thisMonth", "thisYear"
      • "pastWeek", "pastMonth", "pastYear"
      • "lastWeek", "lastMonth", "lastYear"

      Where and are YYYY-MM-DD date formats and period is "day", "week", "month", or "year".

      Parameters

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

      Returns DateSpan

    • Construct for month previous to this month 1..28-31

      Returns DateSpan

    • DateSpan for 3 month quarter previous to this quarter

      Returns DateSpan

    • Construct for week previous to this week sun..sat (uses locale start of week)

      Returns DateSpan

    • Construct for year previous to this year Jan-1..Dec-31

      Returns DateSpan

    • Construct a new DateSpan using a start date and period, or an explicit start date and end date. If a period of week, month, quarter, or year is used, then the start date will be adjusted, if necessary, to the first of week, first of month, first of quarter, or first of year, respectively. If a date is passed as end, then the period is implicitly range.

      Parameters

      • Optionalstart: Date
      • OptionalendOrPer: JsObj
      • ...args: unknown[]

      Returns DateSpan

    • Convenience for make(Date(year, month, 1), DateSpan.month).

      Parameters

      Returns DateSpan

    • Convenience for make(start, DateSpan.week).

      Parameters

      Returns DateSpan

    • Convenience for make(Date(year, Month.jan, 1), DateSpan.year).

      Parameters

      • year: number

      Returns DateSpan

    • Constant for a month period.

      Returns string

    • Construct for last 30days today-30days..today

      Returns DateSpan

    • Construct for last 7 days as today-7days..today

      Returns DateSpan

    • Construct for this past today-365days..today

      Returns DateSpan

    • Constant for a quarter period.

      Returns string

    • Constant for an arbitrary period.

      Returns string

    • Construct for this month as 1..28-31

      Returns DateSpan

    • DateSpan for this 3 month quarter

      Returns DateSpan

    • Construct for this week as sun..sat (uses locale start of week)

      Returns DateSpan

    • Construct for this year Jan-1..Dec-31

      Returns DateSpan

    • Convenience for make(Date.today).

      Returns DateSpan

    • Constant for a week period.

      Returns string

    • Constant for a month period.

      Returns string

    • Convenience for make(Date.today-1day).

      Returns DateSpan