Skip to content

Commit 751fb78

Browse files
author
russom
committed
Change am and pm to lower case and update description.
1 parent e7ff9c7 commit 751fb78

2 files changed

Lines changed: 23 additions & 23 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ function formatAs12HourClock(time) {
44
const minutes = time.slice(3, 5);
55

66
if (hours === 0) {
7-
return `12:${minutes} AM`;
7+
return `12:${minutes} am`;
88
}
99
if (hours === 12) {
10-
return `12:${minutes} PM`;
10+
return `12:${minutes} pm`;
1111
}
1212
if (hours > 12) {
13-
return `${String(hours - 12).padStart(2, "0")}:${minutes} PM`;
13+
return `${String(hours - 12).padStart(2, "0")}:${minutes} pm`;
1414
}
15-
return `${time} AM`;
15+
return `${time} am`;
1616
}
1717

1818
export { formatAs12HourClock };

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,52 @@ import { formatAs12HourClock } from "./timeConverter.js";
22
import assert from "node:assert";
33
import test from "node:test";
44

5+
test("can correctly convert time last minute of the day", function () {
6+
assert.equal(formatAs12HourClock("23:59"), "11:59 pm");
7+
});
8+
9+
test("can correctly convert morning time", function () {
10+
assert.equal(formatAs12HourClock("08:00"), "08:00 am");
11+
});
12+
513
test("can correctly convert time at midnight ", function () {
6-
assert.equal(formatAs12HourClock("00:00"), "12:00 AM");
14+
assert.equal(formatAs12HourClock("00:00"), "12:00 am");
715
});
816

917
test("can correctly convert time just after midnight", function () {
10-
assert.equal(formatAs12HourClock("00:01"), "12:01 AM");
18+
assert.equal(formatAs12HourClock("00:01"), "12:01 am");
1119
});
1220

1321
test("can correctly convert time at the first normal hour", function () {
14-
assert.equal(formatAs12HourClock("01:00"), "01:00 AM");
15-
});
16-
17-
test("can correctly convert morning time", function () {
18-
assert.equal(formatAs12HourClock("08:00"), "08:00 AM");
22+
assert.equal(formatAs12HourClock("01:00"), "01:00 am");
1923
});
2024

2125
test("can correctly convert time on leading zeros in hour and minute", function () {
22-
assert.equal(formatAs12HourClock("09:05"), "09:05 AM");
26+
assert.equal(formatAs12HourClock("09:05"), "09:05 am");
2327
});
2428

2529
test("can correctly convert time just last minute before noon", function () {
26-
assert.equal(formatAs12HourClock("11:59"), "11:59 AM");
30+
assert.equal(formatAs12HourClock("11:59"), "11:59 am");
2731
});
2832

2933
test("can correctly convert time to PM at noon", function () {
30-
assert.equal(formatAs12HourClock("12:00"), "12:00 PM");
34+
assert.equal(formatAs12HourClock("12:00"), "12:00 pm");
3135
});
3236

3337
test("can correctly convert time just afternoon", function () {
34-
assert.equal(formatAs12HourClock("12:01"), "12:01 PM");
38+
assert.equal(formatAs12HourClock("12:01"), "12:01 pm");
3539
});
3640

3741
test("can correctly convert time last minute of the noon hour", function () {
38-
assert.equal(formatAs12HourClock("12:59"), "12:59 PM");
42+
assert.equal(formatAs12HourClock("12:59"), "12:59 pm");
3943
});
4044

4145
test("can correctly convert time first hour after noon", function () {
42-
assert.equal(formatAs12HourClock("13:00"), "01:00 PM");
46+
assert.equal(formatAs12HourClock("13:00"), "01:00 pm");
4347
});
4448

45-
test("correctly convert time after 12:00", function () {
46-
assert.equal(formatAs12HourClock("23:00"), "11:00 PM");
47-
});
48-
49-
test("can correctly convert time last minute of the day", function () {
50-
assert.equal(formatAs12HourClock("23:59"), "11:59 PM");
49+
test("correctly convert time before midnight", function () {
50+
assert.equal(formatAs12HourClock("23:00"), "11:00 pm");
5151
});
5252

5353
/*

0 commit comments

Comments
 (0)