mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
Fixes some logic to runtime calculations format
This commit is contained in:
parent
89416bd714
commit
64c2129b1d
1 changed files with 28 additions and 4 deletions
|
|
@ -98,11 +98,35 @@ const MetadataDetails: React.FC<MetadataDetailsProps> = ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function formatRuntime(runtime: string): string {
|
function formatRuntime(runtime: string): string {
|
||||||
|
// Match formats like "1h55min" or "2h 7min" and convert to "1H 55M" or "2H 7M"
|
||||||
|
// Try to match formats like "1h55min", "2h 7min", "125 min", etc.
|
||||||
|
const match = runtime.match(/(?:(\d+)\s*h\s*)?(\d+)\s*min/i);
|
||||||
|
if (match) {
|
||||||
|
const h = match[1] ? parseInt(match[1], 10) : 0;
|
||||||
|
const m = match[2] ? parseInt(match[2], 10) : 0;
|
||||||
|
if (h > 0) {
|
||||||
|
return `${h}H ${m}M`;
|
||||||
|
}
|
||||||
|
if (m < 60) {
|
||||||
|
return `${m} MIN`;
|
||||||
|
}
|
||||||
|
const hours = Math.floor(m / 60);
|
||||||
|
const mins = m % 60;
|
||||||
|
return hours > 0 ? `${hours}H ${mins}M` : `${mins} MIN`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: treat as minutes if it's a number
|
||||||
const r = parseInt(runtime, 10);
|
const r = parseInt(runtime, 10);
|
||||||
if (isNaN(r) || r < 60) return runtime;
|
if (!isNaN(r)) {
|
||||||
const h = Math.floor(r / 60);
|
if (r < 60) return `${r} MIN`;
|
||||||
const m = r % 60;
|
const h = Math.floor(r / 60);
|
||||||
return `${h}H ${m}MIN`;
|
const m = r % 60;
|
||||||
|
return h > 0 ? `${h}H ${m}M` : `${m} MIN`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If not matched, return as is
|
||||||
|
return runtime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue