Skip to content

Commit fe78cd5

Browse files
author
AlanGit-debug2604
committed
Refactor time formatting logic to correctly handle hours between 12 and 22, ensuring proper AM/PM representation
1 parent 01c7b46 commit fe78cd5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Sprint-3/5-stretch-extend/format-time.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ function formatAs12HourClock(time) {
77
const minutes = time.slice(-2);
88
if (hours >= 24) {
99
return `0${hours - 24}:${minutes} am +1`;
10-
} else if (hours > 12) {
10+
} else if (hours > 22) {
1111
return `${hours - 12}:${minutes} pm`;
12+
} else if (hours > 12) {
13+
return `0${hours - 12}:${minutes} pm`;
1214
} else if (hours > 9) {
1315
return `${hours}:${minutes} am`;
1416
}

0 commit comments

Comments
 (0)