A day of week, such as 'tuesday'.

This class satisfies Enumerable<DayOfWeek>, which means that you can create ranges of days of week:

E.g:

value week = monday..sunday;
value weekend = saturday..sunday;

Note that ranges created this way are always in increasing order, wrapping once last day of week is reached. This means that when you create a range of tuesday..monday, this is equivalent to the following sequence: [tuesday, wednesday, thursday, friday, saturday, sunday, monday]

In order to get the reverse order range, you can use either span operator:

value reverseDaysOfWeek = tuesday:-1;

or explicitly reverse the order of the range like this:

calue reverseDaysOfWeek = (monday..tuesday).reverse();
Initializer
DayOfWeek(Integer integer)
Parameters:
  • integer

    Numeric value of the DayOfWeek.

Attributes
integerSource Codeshared Integer integer

Numeric value of the DayOfWeek.

Inherited Attributes
Attributes inherited from: Object
Attributes inherited from: Enumerable<Other>
Attributes inherited from: Ordinal<Other>
Methods
compareSource Codeshared actual Comparison compare(DayOfWeek other)

Compare days of week.

minusDaysSource Codeshared DayOfWeek minusDays(Integer number)

Returns a day of week that comes number of days before this DayOfWeek.

neighbourSource Codeshared actual DayOfWeek neighbour(Integer offset)

returns n-th neighbour of this day of week.

For example:

assert(sunday.neighbour(0)  == sunday);
assert(sunday.neighbour(1)  == monday);
assert(sunday.neighbour(-1) == saturday);
offsetSource Codeshared actual default Integer offset(DayOfWeek other)

Returns the offset of the other day of week compared to this.

This will always return positive integer such that given any two days of week a and b, the following is always true:

assert(0 <= a.offset(b) <= 6);
plusDaysSource Codeshared DayOfWeek plusDays(Integer number)

Returns a day of week that comes specified number of days after this DayOfWeek.

Inherited Methods
Methods inherited from: Object
Methods inherited from: Comparable<Other>
Methods inherited from: Enumerable<Other>