Skip to content

Commit 153637b

Browse files
committed
Match approved clock formatting cases
Pad single-digit afternoon hours and align edge-case test formatting.
1 parent 6e75e0c commit 153637b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎format-clock-edge-cases/timeConverter.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ function formatAs12HourClock(time) {
77
}
88

99
if (hours > 12) {
10-
return `${hours - 12}:${minutes} pm`;
10+
const pmHours = String(hours - 12).padStart(2, "0");
11+
return `${pmHours}:${minutes} pm`;
1112
}
1213

1314
if (hours === 12) {

‎format-clock-edge-cases/timeConverter.test.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ const cases = [
1010
["11:59", "11:59 am"],
1111
["12:00", "12:00 pm"],
1212
["12:34", "12:34 pm"],
13-
["13:00", "1:00 pm"],
14-
["15:45", "3:45 pm"],
13+
["13:00", "01:00 pm"],
14+
["13:30", "01:30 pm"],
15+
["15:45", "03:45 pm"],
1516
["23:00", "11:00 pm"],
1617
["23:59", "11:59 pm"],
1718
];

0 commit comments

Comments
 (0)