Fix timestamp capping for storage service
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
parent
5fc53ee435
commit
f15d5049f8
5 changed files with 141 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue