Add timestamp utilities with helpful names

This commit is contained in:
Fedor Indutny 2021-03-22 14:08:52 -07:00 committed by GitHub
parent 9fa3359477
commit a75402d290
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 71 additions and 17 deletions

10
ts/util/timestamp.ts Normal file
View file

@ -0,0 +1,10 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export function isMoreRecentThan(timestamp: number, delta: number): boolean {
return timestamp > Date.now() - delta;
}
export function isOlderThan(timestamp: number, delta: number): boolean {
return timestamp <= Date.now() - delta;
}