You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/frontend/src/Utilities/Date/formatTime.js

22 lines
519 B

import moment from 'moment';
function formatTime(date, timeFormat, { includeMinuteZero = false, includeSeconds = false } = {}) {
if (!date) {
return '';
}
const time = moment(date);
if (includeSeconds) {
timeFormat = timeFormat.replace(/\(?:mm\)?/, ':mm:ss');
} else if (includeMinuteZero || time.minute() !== 0) {
timeFormat = timeFormat.replace('(:mm)', ':mm');
} else {
timeFormat = timeFormat.replace('(:mm)', '');
}
return time.format(timeFormat);
}
export default formatTime;