getWeeksAgo()function
getWeeksAgo(target: PossibleDate, current?: PossibleDate, caller: AnyCaller = getWeeksAgo): number
| Param | Type | |
|---|---|---|
target | PossibleDate | Date to count back from. required |
current | PossibleDate | Date to count to (defaults to now). |
caller | AnyCaller | Function to attribute a thrown error to (defaults to getWeeksAgo itself). Defaults to getWeeksAgo |
| Return | |
|---|---|
number | Number of whole weeks from target to current (negative if target is in the future). |
| Throws | |
|---|---|
RequiredError | If target or current cannot be converted to a valid date. |
Count the whole weeks since a date.
- Rounds to the nearest whole week.
Examples
getWeeksAgo(target) // 9