fix: guard formatDuration against NaN/Infinity input
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
18940d0640
commit
da1d14d458
@ -688,6 +688,7 @@ function parseDuration(duration: string): number {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatDuration(seconds: number): string {
|
function formatDuration(seconds: number): string {
|
||||||
|
if (!isFinite(seconds) || seconds < 0) return '00:00:00';
|
||||||
const h = Math.floor(seconds / 3600);
|
const h = Math.floor(seconds / 3600);
|
||||||
const m = Math.floor((seconds % 3600) / 60);
|
const m = Math.floor((seconds % 3600) / 60);
|
||||||
const s = Math.floor(seconds % 60);
|
const s = Math.floor(seconds % 60);
|
||||||
@ -695,6 +696,7 @@ function formatDuration(seconds: number): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatDurationDashed(seconds: number): string {
|
function formatDurationDashed(seconds: number): string {
|
||||||
|
if (!isFinite(seconds) || seconds < 0) return '00-00-00';
|
||||||
const h = Math.floor(seconds / 3600);
|
const h = Math.floor(seconds / 3600);
|
||||||
const m = Math.floor((seconds % 3600) / 60);
|
const m = Math.floor((seconds % 3600) / 60);
|
||||||
const s = Math.floor(seconds % 60);
|
const s = Math.floor(seconds % 60);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user