2021-03-22 21:08:52 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-09-24 17:01:46 +00:00
|
|
|
const ONE_DAY = 24 * 3600 * 1000;
|
|
|
|
|
2021-03-22 21:08:52 +00:00
|
|
|
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;
|
|
|
|
}
|
2021-08-23 22:45:11 +00:00
|
|
|
|
|
|
|
export function isInPast(timestamp: number): boolean {
|
|
|
|
return isOlderThan(timestamp, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isInFuture(timestamp: number): boolean {
|
|
|
|
return isMoreRecentThan(timestamp, 0);
|
|
|
|
}
|
2021-09-24 17:01:46 +00:00
|
|
|
|
|
|
|
export function toDayMillis(timestamp: number): number {
|
|
|
|
return timestamp - (timestamp % ONE_DAY);
|
|
|
|
}
|