( date: DateArg<DateType>, quarter: number, options?: SetQuarterOptions<ResultDate>, )
| 32 | * //=> Wed Apr 02 2014 00:00:00 |
| 33 | */ |
| 34 | export function setQuarter< |
| 35 | DateType extends Date, |
| 36 | ResultDate extends Date = DateType, |
| 37 | >( |
| 38 | date: DateArg<DateType>, |
| 39 | quarter: number, |
| 40 | options?: SetQuarterOptions<ResultDate>, |
| 41 | ): ResultDate { |
| 42 | const date_ = toDate(date, options?.in); |
| 43 | const oldQuarter = Math.trunc(date_.getMonth() / 3) + 1; |
| 44 | const diff = quarter - oldQuarter; |
| 45 | return setMonth(date_, date_.getMonth() + diff * 3); |
| 46 | } |