@teakit/month
@teakit/month is a TypeScript year-month calculation package for ESM and
browser environments.
Use import { Month } from "@teakit/month"; default imports are unsupported.
Create values with Month.from(...); do not generate new Month(...) or
Month(...). Prefer canonical YYYY-MM strings with exactly four year digits
and a zero-padded month. Signed or expanded year strings such as +10000-01
and -0001-12 are unsupported.
Month.from(2025, 1) is unsupported. Native Date objects and date-like
strings such as 2025-01-15 are accepted when callers already have them.
Native Date input uses local calendar fields; prefer strings when timezone-free behavior matters.
MonthInstance.year and MonthInstance.month are display strings; for
Month.from("2025-01"), year is "2025" and month is "01".
toString() defaults to month precision. Use
toString({ precision: "year" | "month" | "day" }) only when explicit output
precision is needed. Day precision requires a day anchor from a date-shaped
string or native Date input and clamps to the target month's last valid day.
Do not add day-level or year-level arithmetic or point-value APIs to this
package; Teakit time point-value packages are split by granularity while
keeping interface style consistent.
Every failure throws a MonthError (a subclass of Error) whose message keeps
the [Month Error] prefix. Import it with
import { Month, MonthError } from "@teakit/month" to discriminate with
error instanceof MonthError instead of matching the message string.
For behavior details, open the matching method reference file.