Fix timestamp capping for storage service

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2025-01-30 13:15:44 -06:00 committed by GitHub
parent 5fc53ee435
commit f15d5049f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 141 additions and 7 deletions

View file

@ -19,7 +19,10 @@ export function getSafeLongFromTimestamp(
return Long.fromNumber(timestamp);
}
export function getTimestampFromLong(value?: Long | null): number {
export function getTimestampFromLong(
value?: Long | null,
maxValue = MAX_SAFE_DATE
): number {
if (!value || value.isNegative()) {
return 0;
}
@ -27,7 +30,7 @@ export function getTimestampFromLong(value?: Long | null): number {
const num = value.toNumber();
if (num > MAX_SAFE_DATE) {
return MAX_SAFE_DATE;
return maxValue;
}
return num;