getHoursUntil()function

getHoursUntil(target: PossibleDate, current?: PossibleDate, caller: AnyCaller = getHoursUntil): number
ParamType
targetPossibleDate
Date to count up to. required
currentPossibleDate
Date to count from (defaults to now).
callerAnyCaller
Function to attribute a thrown error to (defaults to getHoursUntil itself). Defaults to getHoursUntil
Return
number
Number of whole hours 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 whole hours until a date.

  • Rounds to the nearest whole hour, i.e. 1 hour 29 minutes returns 1

Examples

getHoursUntil(target) // 3