isMonth

Returns whether a value is a Month instance. It is a TypeScript type guard and also backs the instanceof Month check.

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

Month.isMonth(Month.from("2025-01")); // true
Month.isMonth("2025-01"); // false
Month.isMonth({ year: "2025", month: "01" }); // false

const value: unknown = Month.from("2025-01");
if (Month.isMonth(value)) {
  value.add(1); // narrowed to MonthInstance
}

API Reference

Signature

Month.isMonth(value: unknown): value is MonthInstance;

Parameters

ParameterTypeRequiredNotes
valueunknownYesValue to test.

Returns

Returns true only for genuine Month instances; false for strings, plain objects (including toObject() output), Date, null, and undefined.

Agent Contract

FieldValue
Kindstatic type guard
Canonical nameisMonth
Mutates receiverNo
Returnsvalue is MonthInstance
Related methodsfrom, toObject

Agent Notes

  • Use isMonth to narrow an unknown before calling instance methods.
  • toObject() output is a plain object, so isMonth returns false for it.