mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Use the same duration format
This commit is contained in:
parent
9778f2db65
commit
6165d5f69e
2 changed files with 19 additions and 10 deletions
|
@ -118,7 +118,7 @@ import '../../elements/emby-button/emby-button';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.RunTimeTicks) {
|
if (item.RunTimeTicks) {
|
||||||
miscInfo.push(datetime.getDisplayRunningTime(item.RunTimeTicks));
|
miscInfo.push(datetime.getDisplayDuration(item.RunTimeTicks));
|
||||||
}
|
}
|
||||||
} else if (item.Type === 'PhotoAlbum' || item.Type === 'BoxSet') {
|
} else if (item.Type === 'PhotoAlbum' || item.Type === 'BoxSet') {
|
||||||
count = item.ChildCount;
|
count = item.ChildCount;
|
||||||
|
@ -256,15 +256,7 @@ import '../../elements/emby-button/emby-button';
|
||||||
if (item.Type === 'Audio') {
|
if (item.Type === 'Audio') {
|
||||||
miscInfo.push(datetime.getDisplayRunningTime(item.RunTimeTicks));
|
miscInfo.push(datetime.getDisplayRunningTime(item.RunTimeTicks));
|
||||||
} else {
|
} else {
|
||||||
const totalMinutes = Math.round(item.RunTimeTicks / 600000000) || 1;
|
miscInfo.push(datetime.getDisplayDuration(item.RunTimeTicks));
|
||||||
const totalHours = Math.floor(totalMinutes / 60);
|
|
||||||
const remainderMinutes = totalMinutes % 60;
|
|
||||||
const result = [];
|
|
||||||
if (totalHours > 0) {
|
|
||||||
result.push(`${totalHours}h`);
|
|
||||||
}
|
|
||||||
result.push(`${remainderMinutes}m`);
|
|
||||||
miscInfo.push(result.join(' '));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,22 @@ import globalize from './globalize';
|
||||||
return new Date(ms);
|
return new Date(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a string in '{}h {}m' format for duration.
|
||||||
|
* @param {number} ticks - Duration in ticks.
|
||||||
|
*/
|
||||||
|
export function getDisplayDuration(ticks) {
|
||||||
|
const totalMinutes = Math.round(ticks / 600000000) || 1;
|
||||||
|
const totalHours = Math.floor(totalMinutes / 60);
|
||||||
|
const remainderMinutes = totalMinutes % 60;
|
||||||
|
const result = [];
|
||||||
|
if (totalHours > 0) {
|
||||||
|
result.push(`${totalHours}h`);
|
||||||
|
}
|
||||||
|
result.push(`${remainderMinutes}m`);
|
||||||
|
return result.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
export function getDisplayRunningTime(ticks) {
|
export function getDisplayRunningTime(ticks) {
|
||||||
const ticksPerHour = 36000000000;
|
const ticksPerHour = 36000000000;
|
||||||
const ticksPerMinute = 600000000;
|
const ticksPerMinute = 600000000;
|
||||||
|
@ -255,6 +271,7 @@ import globalize from './globalize';
|
||||||
export default {
|
export default {
|
||||||
parseISO8601Date: parseISO8601Date,
|
parseISO8601Date: parseISO8601Date,
|
||||||
getDisplayRunningTime: getDisplayRunningTime,
|
getDisplayRunningTime: getDisplayRunningTime,
|
||||||
|
getDisplayDuration,
|
||||||
toLocaleDateString: toLocaleDateString,
|
toLocaleDateString: toLocaleDateString,
|
||||||
toLocaleString: toLocaleString,
|
toLocaleString: toLocaleString,
|
||||||
getDisplayTime: getDisplayTime,
|
getDisplayTime: getDisplayTime,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue