ts-time/DayOfWeek

Consumption

import DayOfWeek, {MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY, DAYS_OF_WEEK} from "ts-time/DayOfWeek";

Default export#

Hierarchy#

  • class DayOfWeek

Description#

There are exactly 7 days of week, with respective numeric values:
  1. MONDAY
  2. TUESDAY
  3. WEDNESDAY
  4. THURSDAY
  5. FRIDAY
  6. SATURDAY
  7. SUNDAY
You can't construct new days of week, you can only get an existing day of week directly or with of method. With that said, the class doesn't provide equals method, as you can merely use JS operator === for equality check.

Fields#

value#

readonly value: number

Numeric value of the day.

Methods#

compareTo#

(other: DayOfWeek): number

other
Day of week to compare to.
returns
  • 0 if this is the same day of week;
  • positive value if this day goes after other;
  • negative value if this day goes before other.
Null and undefined are considered less than anything, except each other.

Note that a method call on null or undefined always leads to an error. So, if your variable may contain null or undefined, use the respective static method instead.

isBefore#

(other: DayOfWeek): boolean

other
Day of week to compare to.
returns
True if this day goes before other. Null and undefined go before anything, except each other.

Note that a method call on null or undefined always leads to an error. So, if your variable may contain null or undefined, use the respective static method instead.

isAfter#

(other: DayOfWeek): boolean

other
Day of week to compare to.
returns
True if this day goes after other. Null and undefined go before anything, except each other.

Note that a method call on null or undefined always leads to an error. So, if your variable may contain null or undefined, use the respective static method instead.

Static methods#

of#

(value: number | DayOfWeek): DayOfWeek throws InvalidDayOfWeekError

value
Numeric value of the day.
returns
DayOfWeek representation of the day.
compareTo#

(x: DayOfWeek, y: DayOfWeek): number

x
One day.
y
Another day.
returns
  • 0 if this is x === y;
  • positive value if x goes after y;
  • negative value if x goes before y.
Null and undefined are considered less than anything, except each other.
isBefore#

(x: DayOfWeek, y: DayOfWeek): boolean

x
One day.
y
Another day.
returns
True if x goes before y. Null and undefined go before anything, except each other.
isAfter#

(x: DayOfWeek, y: DayOfWeek): boolean

x
One day.
y
Another day.
returns
True if x goes after y. Null and undefined go before anything, except each other.

MONDAY#

MONDAY: DayOfWeek

DayOfWeek representation of Monday. Has numeric value of 1.

TUESDAY#

TUESDAY: DayOfWeek

DayOfWeek representation of Tuesday. Has numeric value of 2.

WEDNESDAY#

WEDNESDAY: DayOfWeek

DayOfWeek representation of Wednesday. Has numeric value of 3.

THURSDAY#

THURSDAY: DayOfWeek

DayOfWeek representation of Thursday. Has numeric value of 4.

FRIDAY#

FRIDAY: DayOfWeek

DayOfWeek representation of Friday. Has numeric value of 5.

SATURDAY#

SATURDAY: DayOfWeek

DayOfWeek representation of Saturday. Has numeric value of 6.

SUNDAY#

SUNDAY: DayOfWeek

DayOfWeek representation of Sunday. Has numeric value of 7.

DAYS_OF_WEEK#

DAYS_OF_WEEK: DayOfWeek[]

Array of all days of week, from MONDAY to SUNDAY.