isSameYear

Returns whether the receiver and another value fall in the same calendar year. Only the year is compared; the month and any day anchor are ignored.

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

Month.from("2025-07").isSameYear("2025-01"); // true
Month.from("2025-07").isSameYear("2025-12"); // true
Month.from("2025-07").isSameYear("2026-01"); // false
Month.from("2025-07").isSameYear("2024-12"); // false

Month.isSameYear("2025-01", "2025-12"); // true

API Reference

Signatures

month.isSameYear(other: MonthValue): boolean;
Month.isSameYear(left: MonthValue, right: MonthValue): boolean;

Parameters

ParameterTypeRequiredNotes
otherMonthValueInstance onlyMonth compared against the receiver.
leftMonthValueStatic onlyLeft-hand month.
rightMonthValueStatic onlyRight-hand month.

Returns

Returns true when both months are in the same year; otherwise false.

Throws

  • Throws when an input value is not a valid month.

Agent Contract

FieldValue
Kindinstance method and static helper
Canonical nameisSameYear
AliasesNone
Mutates receiverNo
Returnsboolean
Comparesyear component only
Related methodseq, cmp

Agent Notes

  • isSameYear compares only the year; "2025-01" and "2025-12" are the same year, while "2025-12" and "2026-01" are not. The month and any day anchor are ignored.
  • For full equality use eq; for ordering use cmp.
  • Do not generate startOfYear() or endOfYear(); they are not part of the API.