Merge pull request #163 from CrissZollo/fix-timeline-time

Timeline corrections
This commit is contained in:
tapframe 2025-10-04 20:29:29 +05:30 committed by GitHub
commit 6d4edabb46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -98,11 +98,34 @@ const MetadataDetails: React.FC<MetadataDetailsProps> = ({
}));
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);
if (isNaN(r) || r < 60) return runtime;
const h = Math.floor(r / 60);
const m = r % 60;
return `${h}H ${m}MIN`;
if (!isNaN(r)) {
if (r < 60) return `${r} MIN`;
const h = Math.floor(r / 60);
const m = r % 60;
return h > 0 ? `${h}H ${m}M` : `${m} MIN`;
}
// If not matched, return as is
return runtime;
}
return (
@ -239,7 +262,7 @@ const styles = StyleSheet.create({
metaInfo: {
flexDirection: 'row',
alignItems: 'center',
gap: 12,
gap: 18,
paddingHorizontal: 16,
marginBottom: 12,
},