ts-time/Month

Consumption

import Month, {JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER, MONTHS} from "ts-time/Month";

Default export#

Hierarchy#

  • class Month

Description#

There are exactly 12 months, with respective numeric values:
  1. JANUARY
  2. FEBRUARY
  3. MARCH
  4. APRIL
  5. MAY
  6. JUNE
  7. JULY
  8. AUGUST
  9. SEPTEMBER
  10. OCTOBER
  11. NOVEMBER
  12. DECEMBER
You can't construct new months, you can only get an existing month 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 month.

Methods#

length#

(leapYear: boolean): number

leapYear
Is it a leap year?
returns
Number of days in the month.
compareTo#

(other: Month): number

other
Month to compare to.
returns
  • 0 if this is the same month;
  • positive value if this month goes after other;
  • negative value if this month 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: Month): boolean

other
Month to compare to.
returns
True if this month 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: Month): boolean

other
Month to compare to.
returns
True if this month 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 | Month): Month throws InvalidMonthError

value
Numeric value of the month.
returns
Month representation of the month.
compareTo#

(x: Month, y: Month): number

x
One month.
y
Another month.
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: Month, y: Month): boolean

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

(x: Month, y: Month): boolean

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

JANUARY#

JANUARY: Month

Month representation of January. Has numeric value of 1 and length of 31 days.

FEBRUARY#

FEBRUARY: Month

Month representation of February. Has numeric value of 2 and length of 28/29 days (non-leap/leap years).

MARCH#

MARCH: Month

Month representation of March. Has numeric value of 3 and length of 31 days.

APRIL#

APRIL: Month

Month representation of April. Has numeric value of 4 and length of 30 days.

MAY#

MAY: Month

Month representation of May. Has numeric value of 5 and length of 31 days.

JUNE#

JUNE: Month

Month representation of June. Has numeric value of 6 and length of 30 days.

JULY#

JULY: Month

Month representation of July. Has numeric value of 7 and length of 31 days.

AUGUST#

AUGUST: Month

Month representation of August. Has numeric value of 8 and length of 31 days.

SEPTEMBER#

SEPTEMBER: Month

Month representation of September. Has numeric value of 9 and length of 30 days.

OCTOBER#

OCTOBER: Month

Month representation of October. Has numeric value of 10 and length of 31 days.

NOVEMBER#

NOVEMBER: Month

Month representation of November. Has numeric value of 11 and length of 30 days.

DECEMBER#

DECEMBER: Month

Month representation of December. Has numeric value of 12 and length of 31 days.

MONTHS#

MONTHS: Month[]

Array of all months, from JANUARY to DECEMBER.