An interface to represent a Range between same kinds of Date or DateTime or Time.

no type hierarchy

Attributes
durationSource Codeshared formal Duration duration

Returns the Duration between from and to fields.

Example:

Given: today().to(tomorrow).duration then duration is 86400000 milliseconds.

Given: tomorrow().to(today).duration then duration is -86400000 milliseconds.

fromSource Codeshared formal Element from

The first Element returned by the iterator, if any. This should always produce the same value as iterable.iterator().head. It also represents the caller that created the Range:

Example: today().to(tomorrow) -> in this case today() is the caller/creator of the range.

hashSource Codeshared actual default Integer hash

This implementation respect the constraint that if x==y then x.hash==y.hash.

Refines Object.hash
periodSource Codeshared formal Period period

Returns the Period between from and to fields.

Example:

Given: today().to(tomorrow).duration then duration is 1 day.

Given: tomorrow().to(today).duration then duration is -1 day.

stepSource Codeshared formal UnitOfDate|UnitOfTime step

Customized way to iterate over each element, it does not interfer in from and to fields, but it does not guarantee that to will be included in iterator.

stringSource Codeshared actual default String string

Returns ISO-8601 formatted String representation of this Range.

Reference: https://en.wikipedia.org/wiki/ISO_8601#Time_intervals

Refines Iterable.string ultimately refines Object.string
toSource Codeshared formal Element to

The limit of the Range where.

Example:

Given: today().to(tomorrow) then tomorrow is the to element.

Given: tomorrow.to(today()) then today() is the to element.

Inherited Attributes
Attributes inherited from: Iterable<Element,Absent>
Methods
equalsSource Codeshared actual default Boolean equals(Object other)

Returns true if both: this and other are same type and have equal fields from and to.

gapSource Codeshared formal Range<Element,StepBy>|[] gap(Range<Element,StepBy> other)

Returns empty or a new Range:

  • Each Range is considered a set then [A..B] is equivalent to [B..A]
  • The precision is based on the lowest unit
  • When the new Range exists it will follow these rules:

Given: [A..B] gap [C..D]

When: AB < CD

[1..2] gap [5..6] = (2,5)

[1..2] gap [6..5] = (2,5)

[2..1] gap [5..6] = (2,5)

[2..1] gap [6..5] = (2,5)

Given: [A..B] gap [C..D]

When: AB > CD

[5..6] gap [1..2] = (2,5)

[5..6] gap [2..1] = (2,5)

[6..5] gap [1..2] = (2,5)

[6..5] gap [2..1] = (2,5)
overlapSource Codeshared formal Range<Element,StepBy>|[] overlap(Range<Element,StepBy> other)

Returns empty or a new Range:

  • Each Range is considered a set then [A..B] is equivalent to [B..A]
  • The precision is based on the lowest unit
  • When the new Range exists it will follow these rules:

Given: [A..B] overlap [C..D]

When: AB < CD

[1..6] overlap [3..9] = [3,6]

[1..6] overlap [9..3] = [3,6]

[6..1] overlap [3..9] = [3,6]

[6..1] overlap [9..3] = [3,6]

Given: [A..B] overlap [C..D]

When: AB > CD

[3..9] overlap [1..6] = [3,6]

[3..9] overlap [6..1] = [3,6]

[9..3] overlap [1..6] = [3,6]

[9..3] overlap [6..1] = [3,6]
stepBySource Codeshared formal Range<Element,StepBy> stepBy(StepBy step)

Define how this Range will get next or previous element while iterating.

Inherited Methods
Methods inherited from: Category<Element>
Methods inherited from: Iterable<Element,Absent>