comparison

Compares month values by chronological order.

import { Month } from "@teakit/month";

const month = Month.from("2025-01");

month.cmp("2025-02"); // -1
month.eq("2025-01"); // true
month.lt("2025-02"); // true
month.gt("2024-12"); // true

Month.min("2025-03", "2025-01", "2025-02").toString(); // "2025-01"
Month.max("2025-03", "2025-01", "2025-02").toString(); // "2025-03"

API Reference

Signatures

month.cmp(other: MonthValue): 1 | -1 | 0;
month.eq(other: MonthValue): boolean;
month.ne(other: MonthValue): boolean;
month.gt(other: MonthValue): boolean;
month.ge(other: MonthValue): boolean;
month.lt(other: MonthValue): boolean;
month.le(other: MonthValue): boolean;

Month.cmp(left: MonthValue, right: MonthValue): 1 | -1 | 0;
Month.eq(left: MonthValue, right: MonthValue): boolean;
Month.ne(left: MonthValue, right: MonthValue): boolean;
Month.gt(left: MonthValue, right: MonthValue): boolean;
Month.ge(left: MonthValue, right: MonthValue): boolean;
Month.lt(left: MonthValue, right: MonthValue): boolean;
Month.le(left: MonthValue, right: MonthValue): boolean;
Month.min(...values: MonthValue[]): MonthInstance;
Month.max(...values: MonthValue[]): MonthInstance;

Agent Contract

FieldValue
Kindcomparison
Canonical namescmp, eq, ne, gt, ge, lt, le, min, max
Mutates receiverNo
Orderingchronological
Related methodsdiff

Agent Notes

  • Use Month comparison methods instead of relational operators.
  • Use cmp when a sort callback needs a numeric ordering value.