mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: Project Aphrodite
This commit is contained in:
24
frontend/src/Utilities/Date/formatTimeSpan.js
Normal file
24
frontend/src/Utilities/Date/formatTimeSpan.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import moment from 'moment';
|
||||
import padNumber from 'Utilities/Number/padNumber';
|
||||
|
||||
function formatTimeSpan(timeSpan) {
|
||||
if (!timeSpan) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const duration = moment.duration(timeSpan);
|
||||
const days = duration.get('days');
|
||||
const hours = padNumber(duration.get('hours'), 2);
|
||||
const minutes = padNumber(duration.get('minutes'), 2);
|
||||
const seconds = padNumber(duration.get('seconds'), 2);
|
||||
|
||||
const time = `${hours}:${minutes}:${seconds}`;
|
||||
|
||||
if (days > 0) {
|
||||
return `${days}d ${time}`;
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
export default formatTimeSpan;
|
Reference in New Issue
Block a user