From 0658917ea75d7094ecd8592e61f17b8badfe8e16 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 2 Oct 2026 23:44:03 +0100 Subject: [PATCH 01/11] test for 12:00pm failed --- 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 88f2af094..34c2c1a3a 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -9,3 +9,8 @@ test("correctly convert time after 12:00", 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("12:00"), "12:00 pm"); +}); + From 333dbbc1c001c56db982abf62932e51b5e058446 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 2 Oct 2026 23:47:26 +0100 Subject: [PATCH 02/11] minutes test error 12:30 --- format-clock-edge-cases/timeConverter.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 34c2c1a3a..a5eb6918b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -14,3 +14,7 @@ test("can correctly convert morning time", function() { assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); }); +test("can correctly convert morning time", function() { + assert.equal(formatAs12HourClock("12:30"), "12:30 pm"); +}); + From 7a3baaae9eade26df16965872523222377b6e4f8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 2 Oct 2026 23:59:52 +0100 Subject: [PATCH 03/11] 1:30pm test error --- format-clock-edge-cases/timeConverter.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index a5eb6918b..e8a4412a9 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -18,3 +18,6 @@ test("can correctly convert morning time", function() { assert.equal(formatAs12HourClock("12:30"), "12:30 pm"); }); +test("can correctly convert morning time", function() { + assert.equal(formatAs12HourClock("13:30"), "01:30 pm"); +}); From 3e84b2c2f2e4480affb50e0e49949b72bf3dc636 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 3 Oct 2026 00:49:15 +0100 Subject: [PATCH 04/11] 00:00 to 12am bug --- format-clock-edge-cases/timeConverter.test.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index e8a4412a9..123abc2e6 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -3,21 +3,26 @@ 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:00pm"); }); test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("08:00"), "08:00 am"); + assert.equal(formatAs12HourClock("08:00"), "08:00am"); }); test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); }); test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("12:30"), "12:30 pm"); + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); }); test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("13:30"), "01:30 pm"); + assert.equal(formatAs12HourClock("13:30"), "1:30pm"); }); + +test("can correctly convert morning time", function() { + assert.equal(formatAs12HourClock("00:00"), "12:00am"); +}); + From a87db9c70de7ac1e5cbabe2342a6a62ff2b448bf Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 3 Oct 2026 00:51:05 +0100 Subject: [PATCH 05/11] Fix time formatting in formatAs12HourClock function --- format-clock-edge-cases/timeConverter.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 310c07bd9..67af3c784 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,11 +1,23 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); + const minutes = time.slice(3); + + if (hours === 12) { + return `12:${minutes}pm`; + } + + 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`; } +console.log(formatAs12HourClock("00:00")) export {formatAs12HourClock}; + From 3879758be5f8d46bf93d38bf7b42dd42bb717fa7 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 4 Oct 2026 21:24:13 +0100 Subject: [PATCH 06/11] Fix formatting and spacing in formatAs12HourClock function --- format-clock-edge-cases/timeConverter.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 67af3c784..e303d862a 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,10 +1,9 @@ function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); const minutes = time.slice(3); if (hours === 12) { - return `12:${minutes}pm`; + return `12:${minutes}pm`; } if (hours === 0) { @@ -12,12 +11,10 @@ function formatAs12HourClock(time) { } if (hours > 12) { - return `${hours - 12}:${minutes}pm`; - + return `${hours - 12}:${minutes}pm`; } return `${time}am`; } -console.log(formatAs12HourClock("00:00")) - -export {formatAs12HourClock}; +console.log(formatAs12HourClock("00:00")); +export { formatAs12HourClock }; From f8404e8329bc1fb0ce5dfc62c7312dd975d8e22e Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 4 Oct 2026 21:32:09 +0100 Subject: [PATCH 07/11] Refactor time formatting in formatAs12HourClock function and improve test formatting --- format-clock-edge-cases/timeConverter.js | 4 +-- format-clock-edge-cases/timeConverter.test.js | 27 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index e303d862a..a68176566 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -11,10 +11,10 @@ function formatAs12HourClock(time) { } if (hours > 12) { - return `${hours - 12}:${minutes}pm`; + return `${String(hours - 12).padStart(2, "0")}:${minutes}pm`; } return `${time}am`; } -console.log(formatAs12HourClock("00:00")); +console.log(formatAs12HourClock("13:00")); export { formatAs12HourClock }; diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 123abc2e6..906f8eed0 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -1,28 +1,27 @@ -import {formatAs12HourClock} from "./timeConverter.js"; +import { formatAs12HourClock } from "./timeConverter.js"; import assert from "node:assert"; import test from "node:test"; -test("correctly convert time after 12:00", function(){ - assert.equal(formatAs12HourClock("23:00"), "11:00pm"); +test("correctly convert time after 12:00", function () { + assert.equal(formatAs12HourClock("23:00"), "11:00pm"); }); -test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("08:00"), "08:00am"); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("08:00"), "08:00am"); }); -test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("12:00"), "12:00pm"); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("12:00"), "12:00pm"); }); -test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("12:30"), "12:30pm"); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("12:30"), "12:30pm"); }); -test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("13:30"), "1:30pm"); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("13:30"), "1:30pm"); }); -test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("00:00"), "12:00am"); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("00:00"), "12:00am"); }); - From f9e406f3c5c66256e941842867cfeb76f2007666 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 4 Oct 2026 21:33:46 +0100 Subject: [PATCH 08/11] padStart pm times to stay consistent with am --- format-clock-edge-cases/timeConverter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index a68176566..c81573884 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -15,6 +15,6 @@ function formatAs12HourClock(time) { } return `${time}am`; } -console.log(formatAs12HourClock("13:00")); +console.log(formatAs12HourClock("14:00")); -export { formatAs12HourClock }; +export { formatAs12HourClock }; From c375f66f50789e576a911219c57dd82ff44c8724 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 4 Oct 2026 21:35:05 +0100 Subject: [PATCH 09/11] Fix formatting in export statement for consistency --- format-clock-edge-cases/timeConverter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index c81573884..8b0402793 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -17,4 +17,4 @@ function formatAs12HourClock(time) { } console.log(formatAs12HourClock("14:00")); -export { formatAs12HourClock }; +export { formatAs12HourClock }; From e2ea5334edcca16fd68d360ad509dab7cd946e04 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 4 Oct 2026 21:38:35 +0100 Subject: [PATCH 10/11] Fix time formatting in test for 24-hour to 12-hour conversion --- format-clock-edge-cases/timeConverter.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 906f8eed0..a9dd0aee6 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -19,7 +19,7 @@ test("can correctly convert morning time", function () { }); test("can correctly convert morning time", function () { - assert.equal(formatAs12HourClock("13:30"), "1:30pm"); + assert.equal(formatAs12HourClock("13:30"), "01:30pm"); }); test("can correctly convert morning time", function () { From e0f18e7e1b8b46b701d8a15652a4ef385f9029c6 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sun, 4 Oct 2026 22:15:49 +0100 Subject: [PATCH 11/11] Remove console log statement from formatAs12HourClock function --- format-clock-edge-cases/timeConverter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 8b0402793..73de9ffd9 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -15,6 +15,5 @@ function formatAs12HourClock(time) { } return `${time}am`; } -console.log(formatAs12HourClock("14:00")); export { formatAs12HourClock };