compareYearMonths
Signature
Section titled “Signature”compareYearMonths(a: string, b: string): number | nullCompare two year-month strings (YYYY-MM) in calendar order: year first, then month.
- Accepts both year forms, so
2026-10and+002026-10compare equal. - Negative years sort before year 0:
-000001-12is before0000-01. - Returns
nullif either input is invalid or not in the ISO calendar.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
a | string | year-month string |
b | string | year-month string |
Returns
Section titled “Returns”-1, 0, or 1, or null on invalid input
Examples
Section titled “Examples”import { compareYearMonths } from "@northguild/gmt/plain/compare";
compareYearMonths("2026-09", "2026-10") // -1Source
Section titled “Source”Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else:© 2026 NorthGuild, all rights reserved.