getQuarterForDate
Signature
Section titled “Signature”getQuarterForDate(value: string): numberimport { getQuarterForDate } from "@northguild/gmt/plain/calculate";Return the quarter of the year (1-4) for a given ISO date.
- Returns the quarter (1-4) containing the input date.
- Q1 = months 1-3, Q2 = months 4-6, Q3 = months 7-9, Q4 = months 10-12.
- Validates input using isValidDate.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
ISO PlainDate string |
Returns
Section titled “Returns”number (1-4) or null for invalid input
Examples
Section titled “Examples”getQuarterForDate("2024-01-15") // 1getQuarterForDate("2024-04-15") // 2getQuarterForDate("2024-07-15") // 3getQuarterForDate("2024-10-15") // 4getQuarterForDate("invalid") // null