Weekdays class
Utilities to encode and decode the days in a week into an 8-bit bitfield. A bitfield represents one week with each bit representing a day. It is big-endian with the first bit in the bitfield always being unused.
That is to say, it start with the day with the largest value (Sunday) at the 2nd left-most bit.
For example 0100 0100
, will represent Sunday and Wednesday.
Constructors
- Weekdays()
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
decode(
int encoded) → Iterable< int> -
Decodes the bitfield into days, i.e. (1 to 7) of a week.
encoded
should be between 0 and 128. -
encode(
Iterable< int> week) → int -
Encodes the days of a week into a bitfield. The length of
week
should be less than or equal to7
with elements ranging from 1 to 7. -
parse(
int encoded) → Iterable< bool> -
Parses the bitfield into booleans, i.e.
true
if a digit is 1.encoded
should be between 0 and 128. The returned Iterable is little-endian withtrue
indicating the presence of a day. -
unparse(
Iterable< bool> week) → int -
Encodes the booleans into a bitfield. The length of
week
should be 7.week
is expected to be little-endian withtrue
indicating the presence of a day.