fix: show short video durations accurately
This commit is contained in:
@@ -59,9 +59,14 @@ const toAttachment = (asset: ApiAsset): Attachment => ({
|
||||
});
|
||||
|
||||
const toDuration = (seconds: number | null) => {
|
||||
if (!seconds) return '—';
|
||||
const minutes = Math.round(seconds / 60);
|
||||
return minutes >= 60 ? `${Math.floor(minutes / 60)}h ${minutes % 60}m` : `${minutes}m`;
|
||||
if (!seconds || seconds < 1) return '—';
|
||||
const totalSeconds = Math.round(seconds);
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const remainingSeconds = totalSeconds % 60;
|
||||
if (hours) return `${hours}h ${String(minutes).padStart(2, '0')}min`;
|
||||
if (minutes) return `${minutes}min`;
|
||||
return `${remainingSeconds}s`;
|
||||
};
|
||||
|
||||
const toCourseDuration = (lessons: ApiCourse['lessons']) => {
|
||||
|
||||
Reference in New Issue
Block a user