Function
checkForNow
(
input: number,
relativeTo: Date | number = Date.now(),
threshold: DurationFormat = { seconds: 30 },
)
Source from the content-addressed store, hash-verified
| 405 | } |
| 406 | |
| 407 | export function checkForNow( |
| 408 | input: number, |
| 409 | relativeTo: Date | number = Date.now(), |
| 410 | threshold: DurationFormat = { seconds: 30 }, |
| 411 | ): boolean { |
| 412 | if (Number.isNaN(input)) return false; |
| 413 | const relativeToTs = new Date(relativeTo).getTime(); |
| 414 | const thresholdTs = IntlDuration.durationToMs(threshold); |
| 415 | const diff = Math.abs(input - relativeToTs); |
| 416 | |
| 417 | if (diff > thresholdTs) return false; |
| 418 | return true; |
| 419 | } |
Tested by
no test coverage detected