mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
Merge pull request #163 from CrissZollo/fix-timeline-time
Timeline corrections
This commit is contained in:
commit
6d4edabb46
1 changed files with 28 additions and 5 deletions
|
|
@ -98,11 +98,34 @@ const MetadataDetails: React.FC<MetadataDetailsProps> = ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function formatRuntime(runtime: string): string {
|
function formatRuntime(runtime: string): string {
|
||||||
|
// 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 (
|
||||||
|
|
@ -239,7 +262,7 @@ const styles = StyleSheet.create({
|
||||||
metaInfo: {
|
metaInfo: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
gap: 12,
|
gap: 18,
|
||||||
paddingHorizontal: 16,
|
paddingHorizontal: 16,
|
||||||
marginBottom: 12,
|
marginBottom: 12,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue