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)
Return display name for this span. If explicit
is true,
display actual dates, as opposed to Today
or Yesterday
.
Optional
explicit: booleanIterate each month in this date range as a range of first to last day in each month.
Inclusive end date for this span.
Hash is based on start/end/period.
Convenience for period == DateSpan.day
Convenience for period == DateSpan.month
Convenience for period == DateSpan.quarter
Convenience for period == DateSpan.range
Convenience for period == DateSpan.week
Convenience for period == DateSpan.year
Return the next DateSpan based on the period:
Get number of days in this span.
Return the previous DateSpan based on the period:
Start date for this span.
Return axon representation for this span.
Get an immutable representation of this instance or throw NotImmutableErr if this object cannot be represented as an immutable:
Str representation is "
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.
This method called whenever an it-block is applied to an
object. The default implementation calls the function with this
,
and then returns this
.
Static
dayConstant for a day period.
Static
echoWrite 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.
Optional
x: JsObjStatic
fromConstruct DateSpan from Str. This method supports parsing from the following formats:
Where
Optional
checked: booleanStatic
lastConstruct for month previous to this month 1..28-31
Static
lastDateSpan for 3 month quarter previous to this quarter
Static
lastConstruct for week previous to this week sun..sat
(uses
locale start of week)
Static
lastConstruct for year previous to this year Jan-1..Dec-31
Static
makeConstruct 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
.
Static
makeStatic
makeStatic
makeConvenience for make(Date(year, Month.jan, 1), DateSpan.year)
.
Static
monthConstant for a month period.
Static
pastConstruct for last 30days today-30days..today
Static
pastConstruct for last 7 days as today-7days..today
Static
pastConstruct for this past today-365days..today
Static
quarterConstant for a quarter period.
Static
rangeConstant for an arbitrary period.
Static
thisConstruct for this month as 1..28-31
Static
thisDateSpan for this 3 month quarter
Static
thisConstruct for this week as sun..sat
(uses locale start of
week)
Static
thisConstruct for this year Jan-1..Dec-31
Static
todayConvenience for make(Date.today)
.
Static
weekConstant for a week period.
Static
yearConstant for a month period.
Static
yesterdayConvenience for make(Date.today-1day)
.
DateSpan models a span of time between two dates.