Truncate lastHeartbeat to day millis
This commit is contained in:
parent
7adfd1a4e7
commit
af66a5b265
3 changed files with 28 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
const ONE_DAY = 24 * 3600 * 1000;
|
||||
|
||||
export function isMoreRecentThan(timestamp: number, delta: number): boolean {
|
||||
return timestamp > Date.now() - delta;
|
||||
}
|
||||
|
@ -16,3 +18,7 @@ export function isInPast(timestamp: number): boolean {
|
|||
export function isInFuture(timestamp: number): boolean {
|
||||
return isMoreRecentThan(timestamp, 0);
|
||||
}
|
||||
|
||||
export function toDayMillis(timestamp: number): number {
|
||||
return timestamp - (timestamp % ONE_DAY);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue