13 lines
500 B
TypeScript
13 lines
500 B
TypeScript
export function retryCountdownLabel(milliseconds: number): string {
|
|
const totalSeconds = Math.max(0, Math.ceil(milliseconds / 1_000));
|
|
const minutes = Math.floor(totalSeconds / 60);
|
|
const seconds = totalSeconds % 60;
|
|
return `${minutes}:${seconds.toString().padStart(2, "0")}`;
|
|
}
|
|
|
|
export function parseRetryAt(value: string | undefined): number | undefined {
|
|
if (!value) return undefined;
|
|
const timestamp = Date.parse(value);
|
|
return Number.isFinite(timestamp) ? timestamp : undefined;
|
|
}
|