1
0
Fork 0
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:
Dmitry Lyzo 2021-09-11 12:44:49 +03:00
parent 9778f2db65
commit 6165d5f69e
2 changed files with 19 additions and 10 deletions

View file

@ -57,6 +57,22 @@ import globalize from './globalize';
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) {
const ticksPerHour = 36000000000;
const ticksPerMinute = 600000000;
@ -255,6 +271,7 @@ import globalize from './globalize';
export default {
parseISO8601Date: parseISO8601Date,
getDisplayRunningTime: getDisplayRunningTime,
getDisplayDuration,
toLocaleDateString: toLocaleDateString,
toLocaleString: toLocaleString,
getDisplayTime: getDisplayTime,