( date: DateArg<DateType>, amount: number, options?: AddDaysOptions<ResultDate> | undefined, )
| 51 | * //=> "2014-09-11" |
| 52 | */ |
| 53 | export function addDays< |
| 54 | DateType extends Date, |
| 55 | ResultDate extends Date = DateType, |
| 56 | >( |
| 57 | date: DateArg<DateType>, |
| 58 | amount: number, |
| 59 | options?: AddDaysOptions<ResultDate> | undefined, |
| 60 | ): ResultDate { |
| 61 | const _date = toDate(date, options?.in); |
| 62 | if (isNaN(amount)) return constructFrom(options?.in || date, NaN); |
| 63 | |
| 64 | // If 0 days, no-op to avoid changing times in the hour before end of DST |
| 65 | if (!amount) return _date; |
| 66 | |
| 67 | _date.setDate(_date.getDate() + amount); |
| 68 | return _date; |
| 69 | } |
no test coverage detected