mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 04:13:47 +00:00
refactor: consistent time formatting for 12h mode
This commit is contained in:
committed by
Carlos Valente
parent
50c91f976b
commit
0e3b3bcf9a
@@ -43,8 +43,8 @@ describe('formatTime()', () => {
|
||||
|
||||
describe('formatDuration()', () => {
|
||||
it('formats durations correctly', () => {
|
||||
expect(formatDuration(0)).toBe('0h 0m');
|
||||
expect(formatDuration(-5000)).toBe('0h 0m');
|
||||
expect(formatDuration(0)).toBe('0m');
|
||||
expect(formatDuration(-5000)).toBe('0m');
|
||||
expect(formatDuration(MILLIS_PER_MINUTE)).toBe('1m');
|
||||
expect(formatDuration(6 * MILLIS_PER_MINUTE + 11 * MILLIS_PER_SECOND)).toBe('6m');
|
||||
expect(formatDuration(MILLIS_PER_MINUTE * 10)).toBe('10m');
|
||||
|
||||
@@ -112,7 +112,7 @@ export const formatTime = (
|
||||
export function formatDuration(duration: number, hideSeconds = true): string {
|
||||
// durations should never be negative, we handle it here to flag if there is an issue in future
|
||||
if (duration <= 0) {
|
||||
return '0h 0m';
|
||||
return '0m';
|
||||
}
|
||||
|
||||
const hours = Math.floor(duration / MILLIS_PER_HOUR);
|
||||
|
||||
Reference in New Issue
Block a user