Skip to content

Commit 4a1bac7

Browse files
committed
I think I fixed the bug.
1 parent d84b6cc commit 4a1bac7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Time/timeUtils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ export function toHourOutputFormat(
265265
if (is24Hour) {
266266
return newHours
267267
}
268-
if ((!is24Hour && previousHours === 0) || newHours === 0) {
268+
if (previousHours === 0 && newHours !== 0) {
269+
return newHours - 12 < 0 ? newHours : newHours - 12
270+
}
271+
if (previousHours >= 12 && newHours < 12) {
269272
return newHours + 12
270273
}
271274
return newHours

src/__tests__/Time/timeUtils.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('timeUtils', () => {
7878
})
7979

8080
it('should return correct hour output format when not is24Hour', () => {
81-
expect(toHourOutputFormat(11, 13, false)).toBe(11)
81+
expect(toHourOutputFormat(11, 13, false)).toBe(23)
8282
})
8383

8484
it('should return correct hour output format when is24Hour', () => {

0 commit comments

Comments
 (0)