getMonthsUntil()function
getMonthsUntil(target: PossibleDate, current?: PossibleDate, caller: AnyCaller = getMonthsUntil): number
| Param | Type | |
|---|---|---|
target | PossibleDate | Date to count up to. required |
current | PossibleDate | Date to count from (defaults to now). |
caller | AnyCaller | Function to attribute a thrown error to (defaults to getMonthsUntil itself). Defaults to getMonthsUntil |
| Return | |
|---|---|
number | Number of calendar months from current to target (negative if target is in the past). |
| Throws | |
|---|---|
RequiredError | If target or current cannot be converted to a valid date. |
Count the calendar months until a date.
- e.g. from March 31st to April 1st is 1 month, even though it's only 1 day.
Examples
getMonthsUntil(target) // 14