From 301ea630acfa482fd155e83c79c874c0622a453d Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 14:46:02 +0100 Subject: [PATCH 01/17] List edge cases for test. --- format-clock-edge-cases/timeConverter.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 88f2af094..485e13c8b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -9,3 +9,18 @@ test("correctly convert time after 12:00", function(){ test("can correctly convert morning time", function() { assert.equal(formatAs12HourClock("08:00"), "08:00 am"); }); + +/* +Edge cases to be tested. + +1. 00:00 +2. 00:01 +3. 01:00 +4. 09:05 +5. 11:59 +6. 23:59 +7. 12:00 +8. 12:01 +9. 12:59 +10.13:00 +*/ \ No newline at end of file From 2501561c60d5751117e7f4369848fcd7c950ceac Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 20:12:24 +0100 Subject: [PATCH 02/17] Update list. --- format-clock-edge-cases/timeConverter.test.js | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 485e13c8b..8003a1feb 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -6,21 +6,26 @@ test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); }); -test("can correctly convert morning time", function() { +test("can correctly convert morning time", function(){ assert.equal(formatAs12HourClock("08:00"), "08:00 am"); }); +test("can correctly convert morning time", function (){ + assert.equal(formatAs12HourClock("00:00"), "12:00 am"); +}); + /* Edge cases to be tested. + Input Expected What it tests -1. 00:00 -2. 00:01 -3. 01:00 -4. 09:05 -5. 11:59 -6. 23:59 -7. 12:00 -8. 12:01 -9. 12:59 -10.13:00 +1. 00:00 -> 12:00 am Midnight: hour 0 becomes 12 +2. 00:01 -> 12:01 am Just after midnight, still 12 +3. 01:00 -> 01:00 am First normal morning hour +4. 09:05 -> 09:05 am Leading zeros in hour and minute +5. 11:59 -> 11:59 am Last minute before noon +6. 23:59 -> 11:59 pm Last minute of the day +7. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 +8. 12:01 -> 12:01 pm Just after noon, must not become 00 +9. 12:59 -> 12:59 pm Last minute of the noon hour +10.13:00 -> 01:00 pm First hour after noon: 13 - 12, padded */ \ No newline at end of file From 63e477b4d8dc96b53edf7d343581a5d6e223335b Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 20:36:21 +0100 Subject: [PATCH 03/17] Add an if condition to check midnight --- format-clock-edge-cases/timeConverter.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 310c07bd9..ccd71295f 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,11 +1,16 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); + const minutes = time.slice(3, 5); + + if (hours === 0) { + return `12:${minutes} AM` + } if (hours > 12) { - return `${hours - 12}:00 pm`; + return `${hours - 12}:${minutes} PM`; } - return `${time} am`; + return `${time} AM`; } export {formatAs12HourClock}; From a8e1b2d657bc6701d1b2662d9d3f378c2921e33c Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 20:37:04 +0100 Subject: [PATCH 04/17] Add another case to test midnight --- format-clock-edge-cases/timeConverter.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 8003a1feb..4bd33a0fe 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -3,15 +3,15 @@ import assert from "node:assert"; import test from "node:test"; test("correctly convert time after 12:00", function(){ - assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); + assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); test("can correctly convert morning time", function(){ - assert.equal(formatAs12HourClock("08:00"), "08:00 am"); + assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); }); -test("can correctly convert morning time", function (){ - assert.equal(formatAs12HourClock("00:00"), "12:00 am"); +test("can correctly convert midnight time", function (){ + assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); }); /* From 9e2cef84be358c6b92e7f4fed3918571a0bf23d7 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:05:07 +0100 Subject: [PATCH 05/17] Add test case 00:01 to 12:01 am --- format-clock-edge-cases/timeConverter.test.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 4bd33a0fe..2c21a2e8c 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -2,6 +2,14 @@ import {formatAs12HourClock} from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; +test("can correctly convert midnight time", function () { + assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); +}); + +test("can correctly convert just after midnight", function () { + assert.equal(formatAs12HourClock("00:01"), "12:01 AM"); +}); + test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); @@ -10,9 +18,7 @@ test("can correctly convert morning time", function(){ assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); }); -test("can correctly convert midnight time", function (){ - assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); -}); + /* Edge cases to be tested. From 2ba2e3421223ea5b7d3424a55b2909c481067ee1 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:05:53 +0100 Subject: [PATCH 06/17] Add condition for checking midday 12 pm --- format-clock-edge-cases/timeConverter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index ccd71295f..0e9e5dc92 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -6,7 +6,9 @@ function formatAs12HourClock(time) { if (hours === 0) { return `12:${minutes} AM` } - + if (hours === 12) { + return `12:${minutes} PM`; + } if (hours > 12) { return `${hours - 12}:${minutes} PM`; } From 06d5f9196609421da4bfad96d57138dc34a5f1d5 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:08:52 +0100 Subject: [PATCH 07/17] Add test case for 01:00 to 01:00 am --- format-clock-edge-cases/timeConverter.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 2c21a2e8c..89d71751f 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -10,6 +10,11 @@ test("can correctly convert just after midnight", function () { assert.equal(formatAs12HourClock("00:01"), "12:01 AM"); }); +test("can correctly convert first normal hour", function () { + assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); +}); + + test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); From 3dc6da6c1f66800bbf9ad12ded58c2f35c074fb7 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:12:29 +0100 Subject: [PATCH 08/17] Add test case for 11:59 to 11:59 am --- format-clock-edge-cases/timeConverter.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 89d71751f..181110f5d 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -14,6 +14,13 @@ test("can correctly convert first normal hour", function () { assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); }); +test("can correctly convert leading zeros in hour and minute", function () { + assert.equal(formatAs12HourClock("09:05"), "09:05 AM"); +}); + +test("can correctly convert last minute before noon", function () { + assert.equal(formatAs12HourClock("11:59"), "11:59 AM"); +}); test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); From 1e6cb55cff9ebed1dba684a035546a3bf2e73b1a Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:20:54 +0100 Subject: [PATCH 09/17] Add test case for 12:01 to 12:01 pm --- format-clock-edge-cases/timeConverter.test.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 181110f5d..a40314267 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -14,6 +14,10 @@ test("can correctly convert first normal hour", function () { assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); }); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); +}); + test("can correctly convert leading zeros in hour and minute", function () { assert.equal(formatAs12HourClock("09:05"), "09:05 AM"); }); @@ -22,13 +26,19 @@ test("can correctly convert last minute before noon", function () { assert.equal(formatAs12HourClock("11:59"), "11:59 AM"); }); +test("can correctly convert time to PM noon", function () { + assert.equal(formatAs12HourClock("12:00"), "12:00 PM"); +}); + +test("can correctly convert time just afternoon", function () { + assert.equal(formatAs12HourClock("12:01"), "12:01 PM"); +}); + test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); -test("can correctly convert morning time", function(){ - assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); -}); + @@ -41,9 +51,10 @@ Edge cases to be tested. 3. 01:00 -> 01:00 am First normal morning hour 4. 09:05 -> 09:05 am Leading zeros in hour and minute 5. 11:59 -> 11:59 am Last minute before noon -6. 23:59 -> 11:59 pm Last minute of the day + 7. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 8. 12:01 -> 12:01 pm Just after noon, must not become 00 9. 12:59 -> 12:59 pm Last minute of the noon hour 10.13:00 -> 01:00 pm First hour after noon: 13 - 12, padded +6. 23:59 -> 11:59 pm Last minute of the day */ \ No newline at end of file From 61b2ce70c7cb54298572a6b4dab7cb03c596dcaf Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:25:30 +0100 Subject: [PATCH 10/17] Add test case for 13:00 to 1:00 pm --- format-clock-edge-cases/timeConverter.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index a40314267..fbf92b1da 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -34,6 +34,14 @@ test("can correctly convert time just afternoon", function () { assert.equal(formatAs12HourClock("12:01"), "12:01 PM"); }); +test("can correctly convert time last minute of the noon hour", function () { + assert.equal(formatAs12HourClock("12:59"), "12:59 PM"); +}); + +test("can correctly convert time first hour after noon", function () { + assert.equal(formatAs12HourClock("13:00"), "1:00 PM"); +}); + test("correctly convert time after 12:00", function(){ assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); From 040786906e6dd059ad1748bb69e7559d30acac80 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:28:50 +0100 Subject: [PATCH 11/17] Add test case fo 23:59 to 11:59 pm --- format-clock-edge-cases/timeConverter.test.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index fbf92b1da..ffedaea52 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -1,4 +1,4 @@ -import {formatAs12HourClock} from "./timeConverter.js"; +import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; @@ -42,13 +42,13 @@ test("can correctly convert time first hour after noon", function () { assert.equal(formatAs12HourClock("13:00"), "1:00 PM"); }); -test("correctly convert time after 12:00", function(){ - assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); +test("correctly convert time after 12:00", function () { + assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); }); - - - +test("can correctly convert time last minute of the day", function () { + assert.equal(formatAs12HourClock("23:59"), "11:59 PM"); +}); /* Edge cases to be tested. @@ -59,10 +59,9 @@ Edge cases to be tested. 3. 01:00 -> 01:00 am First normal morning hour 4. 09:05 -> 09:05 am Leading zeros in hour and minute 5. 11:59 -> 11:59 am Last minute before noon - -7. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 -8. 12:01 -> 12:01 pm Just after noon, must not become 00 -9. 12:59 -> 12:59 pm Last minute of the noon hour -10.13:00 -> 01:00 pm First hour after noon: 13 - 12, padded -6. 23:59 -> 11:59 pm Last minute of the day -*/ \ No newline at end of file +6. 12:00 -> 12:00 pm Noon: switches to pm, hour stays 12 +7. 12:01 -> 12:01 pm Just after noon, must not become 00 +8. 12:59 -> 12:59 pm Last minute of the noon hour +9. 13:00 -> 01:00 pm First hour after noon: 13 - 12, padded +10.23:59 -> 11:59 pm Last minute of the day +*/ From 06d3f9a0c6958076566110dae7ed8b1265059d31 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:36:26 +0100 Subject: [PATCH 12/17] Add padStart method to hours --- format-clock-edge-cases/timeConverter.js | 2 +- format-clock-edge-cases/timeConverter.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 0e9e5dc92..9703a7fea 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,6 +1,6 @@ function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); + const hours = Number(time.slice(0, 2).padStart(2, 0)); const minutes = time.slice(3, 5); if (hours === 0) { diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index ffedaea52..1803282b5 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -39,7 +39,7 @@ test("can correctly convert time last minute of the noon hour", function () { }); test("can correctly convert time first hour after noon", function () { - assert.equal(formatAs12HourClock("13:00"), "1:00 PM"); + assert.equal(formatAs12HourClock("13:00"), "01:00 PM"); }); test("correctly convert time after 12:00", function () { From 598f744790e7497234e6b954abc127e280707755 Mon Sep 17 00:00:00 2001 From: russom Date: Mon, 28 Sep 2026 21:42:18 +0100 Subject: [PATCH 13/17] Add more description. --- format-clock-edge-cases/timeConverter.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 1803282b5..f3ffcea1e 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -2,15 +2,15 @@ import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; -test("can correctly convert midnight time", function () { +test("can correctly convert time at midnight ", function () { assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); }); -test("can correctly convert just after midnight", function () { +test("can correctly convert time just after midnight", function () { assert.equal(formatAs12HourClock("00:01"), "12:01 AM"); }); -test("can correctly convert first normal hour", function () { +test("can correctly convert time at the first normal hour", function () { assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); }); @@ -18,15 +18,15 @@ test("can correctly convert morning time", function () { assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); }); -test("can correctly convert leading zeros in hour and minute", function () { +test("can correctly convert time on leading zeros in hour and minute", function () { assert.equal(formatAs12HourClock("09:05"), "09:05 AM"); }); -test("can correctly convert last minute before noon", function () { +test("can correctly convert time just last minute before noon", function () { assert.equal(formatAs12HourClock("11:59"), "11:59 AM"); }); -test("can correctly convert time to PM noon", function () { +test("can correctly convert time to PM at noon", function () { assert.equal(formatAs12HourClock("12:00"), "12:00 PM"); }); From e6fde3bd32233e9e618bc5ad607ef8182ed4337c Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 29 Sep 2026 22:31:32 +0100 Subject: [PATCH 14/17] Add padStart method to convert 23:00 to 01:00pm --- format-clock-edge-cases/timeConverter.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 9703a7fea..489779331 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,18 +1,19 @@ function formatAs12HourClock(time) { + const hours = Number(time.slice(0, 2)); - const hours = Number(time.slice(0, 2).padStart(2, 0)); const minutes = time.slice(3, 5); if (hours === 0) { - return `12:${minutes} AM` + return `12:${minutes} AM`; } if (hours === 12) { return `12:${minutes} PM`; } if (hours > 12) { - return `${hours - 12}:${minutes} PM`; + const paddedHours = String(hours - 12).padStart(2, "0"); + return `${paddedHours}:${minutes} PM`; } return `${time} AM`; } -export {formatAs12HourClock}; +export { formatAs12HourClock }; From c2f743cc9af42331cdaf0ed8e70d589b6d160355 Mon Sep 17 00:00:00 2001 From: russom Date: Tue, 29 Sep 2026 22:34:46 +0100 Subject: [PATCH 15/17] Edit comments --- format-clock-edge-cases/timeConverter.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index f3ffcea1e..5208d6384 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -53,7 +53,6 @@ test("can correctly convert time last minute of the day", function () { /* Edge cases to be tested. Input Expected What it tests - 1. 00:00 -> 12:00 am Midnight: hour 0 becomes 12 2. 00:01 -> 12:01 am Just after midnight, still 12 3. 01:00 -> 01:00 am First normal morning hour From e7ff9c7e7aeb92a258a202676cb92762eee1ec71 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 13:09:10 +0100 Subject: [PATCH 16/17] Inline code directly into return statement --- format-clock-edge-cases/timeConverter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 489779331..a784d125f 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -10,8 +10,7 @@ function formatAs12HourClock(time) { return `12:${minutes} PM`; } if (hours > 12) { - const paddedHours = String(hours - 12).padStart(2, "0"); - return `${paddedHours}:${minutes} PM`; + return `${String(hours - 12).padStart(2, "0")}:${minutes} PM`; } return `${time} AM`; } From 751fb787e8c9314b5ce60dbce71399fc6cdc5110 Mon Sep 17 00:00:00 2001 From: russom Date: Wed, 30 Sep 2026 20:55:15 +0100 Subject: [PATCH 17/17] Change am and pm to lower case and update description. --- format-clock-edge-cases/timeConverter.js | 8 ++-- format-clock-edge-cases/timeConverter.test.js | 38 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index a784d125f..192894d77 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -4,15 +4,15 @@ function formatAs12HourClock(time) { const minutes = time.slice(3, 5); if (hours === 0) { - return `12:${minutes} AM`; + return `12:${minutes} am`; } if (hours === 12) { - return `12:${minutes} PM`; + return `12:${minutes} pm`; } if (hours > 12) { - return `${String(hours - 12).padStart(2, "0")}:${minutes} PM`; + return `${String(hours - 12).padStart(2, "0")}:${minutes} pm`; } - return `${time} AM`; + return `${time} am`; } export { formatAs12HourClock }; diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 5208d6384..8889b2c7b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -2,52 +2,52 @@ import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; +test("can correctly convert time last minute of the day", function () { + assert.equal(formatAs12HourClock("23:59"), "11:59 pm"); +}); + +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("08:00"), "08:00 am"); +}); + test("can correctly convert time at midnight ", function () { - assert.equal(formatAs12HourClock("00:00"), "12:00 AM"); + assert.equal(formatAs12HourClock("00:00"), "12:00 am"); }); test("can correctly convert time just after midnight", function () { - assert.equal(formatAs12HourClock("00:01"), "12:01 AM"); + assert.equal(formatAs12HourClock("00:01"), "12:01 am"); }); test("can correctly convert time at the first normal hour", function () { - assert.equal(formatAs12HourClock("01:00"), "01:00 AM"); -}); - -test("can correctly convert morning time", function () { - assert.equal(formatAs12HourClock("08:00"), "08:00 AM"); + assert.equal(formatAs12HourClock("01:00"), "01:00 am"); }); test("can correctly convert time on leading zeros in hour and minute", function () { - assert.equal(formatAs12HourClock("09:05"), "09:05 AM"); + assert.equal(formatAs12HourClock("09:05"), "09:05 am"); }); test("can correctly convert time just last minute before noon", function () { - assert.equal(formatAs12HourClock("11:59"), "11:59 AM"); + assert.equal(formatAs12HourClock("11:59"), "11:59 am"); }); test("can correctly convert time to PM at noon", function () { - assert.equal(formatAs12HourClock("12:00"), "12:00 PM"); + assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); }); test("can correctly convert time just afternoon", function () { - assert.equal(formatAs12HourClock("12:01"), "12:01 PM"); + assert.equal(formatAs12HourClock("12:01"), "12:01 pm"); }); test("can correctly convert time last minute of the noon hour", function () { - assert.equal(formatAs12HourClock("12:59"), "12:59 PM"); + assert.equal(formatAs12HourClock("12:59"), "12:59 pm"); }); test("can correctly convert time first hour after noon", function () { - assert.equal(formatAs12HourClock("13:00"), "01:00 PM"); + assert.equal(formatAs12HourClock("13:00"), "01:00 pm"); }); -test("correctly convert time after 12:00", function () { - assert.equal(formatAs12HourClock("23:00"), "11:00 PM"); -}); - -test("can correctly convert time last minute of the day", function () { - assert.equal(formatAs12HourClock("23:59"), "11:59 PM"); +test("correctly convert time before midnight", function () { + assert.equal(formatAs12HourClock("23:00"), "11:00 pm"); }); /*