getQuarter
Signature
Section titled “Signature”getQuarter(value: string, optionsArg?: { fiscalYearStartMonth: number; yearLabel: FiscalYearLabel; }): { year: number; quarter: number; } | nullReturn the quarter value falls in, as a year and a quarter number.
- With no options these are the calendar quarters: Q1 is January to March, and
yearis the calendar year. - With
options, these are fiscal quarters. The fiscal year starts on day 1 offiscalYearStartMonth, andyearLabelnames it:"startYear","endYear", or"majorityYear"(the calendar year holding the most of its days). Both are required, and there is no default. Start months 1 to 7 put most days in the start year, and 8 to 12 put most in the end year. valuemust be zoneless — an ISO date or datetime, asisValidIsoDateLikeaccepts. SeegetIsoWeekDatefor why a moment is not accepted here.- Returns null on invalid input, including
optionswithout both fields, afiscalYearStartMonththat is not an integer from 1 to 12, or an unrecognisedyearLabel.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | zoneless ISO 8601 date or datetime string (e.g. “2024-06-15”) |
Options
Section titled “Options”optionsArg
The fiscal year’s start month and the rule that names it
| Option | Type | Default | Description |
|---|---|---|---|
fiscalYearStartMonth | number | Required | The month the fiscal year starts in, 1 (January) through 12. A date before it belongs to the previous fiscal year, so with 4 the date "2024-03-31" is in that year’s Q4. |
yearLabel | "startYear" | "endYear" | "majorityYear" (FiscalYearLabel) | Required | The calendar year that names a fiscal year. See FiscalYearLabel. |
Returns
Section titled “Returns”{ year, quarter }, or null on invalid input
Members
| Member | Type | Description |
|---|---|---|
year | number | The year that names the quarter’s year: the calendar year with no options, otherwise the one yearLabel picks. |
quarter | number | The quarter of that year, 1 through 4. Quarter 1 begins in January with no options, and in the fiscalYearStartMonth month otherwise. |
Related types
Section titled “Related types”Examples
Section titled “Examples”import { getQuarter } from "@northguild/gmt/calendar/calculate";
getQuarter("2024-06-15") // { year: 2024, quarter: 2 }Source
Section titled “Source”Accessibility
© 2026 NorthGuild · Licences
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.