Fix UI for invalid timestamps

This commit is contained in:
Fedor Indutny 2024-12-19 11:15:52 -08:00 committed by GitHub
parent 187d06fd69
commit 1c933af6ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 4 deletions

View file

@ -206,3 +206,10 @@ export function formatDate(
year: 'numeric',
});
}
const MAX_SAFE_DATE = 8640000000000000;
const MIN_SAFE_DATE = -8640000000000000;
export function toBoundedDate(timestamp: number): Date {
return new Date(Math.max(MIN_SAFE_DATE, Math.min(timestamp, MAX_SAFE_DATE)));
}