startOfQuarterForDate
Signature
Section titled “Signature”startOfQuarterForDate(value: string): stringimport { startOfQuarterForDate } from "@northguild/gmt/plain/calculate";Return the first day of the quarter for a given ISO date.
- Returns the first day (month and day set to 1) of the quarter containing the input date.
- Q1 returns “01-01”, Q2 returns “04-01”, Q3 returns “07-01”, Q4 returns “10-01”.
- Validates input using isValidDate.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
ISO PlainDate string |
Returns
Section titled “Returns”ISO PlainDate string for the first day of the quarter, or “” on invalid input
Examples
Section titled “Examples”startOfQuarterForDate("2024-03-15") // "2024-01-01"startOfQuarterForDate("2024-06-15") // "2024-04-01"startOfQuarterForDate("2024-09-15") // "2024-07-01"startOfQuarterForDate("2024-12-15") // "2024-10-01"startOfQuarterForDate("invalid") // ""