From f66d02c35f1f063ade720b4d3999e7b6d2d21195 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 13:45:53 +0100 Subject: [PATCH 01/27] added a test for 24:00 and test failed --- 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 88f2af094..cdea1e0b2 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -9,3 +9,7 @@ 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 midnight ", function(){ + + assert.equal(formatAs12HourClock("24:00"), "12:00 am") +}); \ No newline at end of file From 3ce6795e3715e483d551965bfc45a929582893b0 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 13:50:18 +0100 Subject: [PATCH 02/27] fixed a bug to return12:00 when time given 24:00 --- 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 310c07bd9..96f27d8f7 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,7 +1,9 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); - + if (time === "00:00"){ + return `12:00` + } if (hours > 12) { return `${hours - 12}:00 pm`; } From 0ec1be76aa2fbf5632de82c44cb473ce798bd90c Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 13:53:17 +0100 Subject: [PATCH 03/27] fixed bug changed time ===24:00 and added am at line 4 and 5 --- 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 96f27d8f7..e76d35f4f 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,8 +1,8 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); - if (time === "00:00"){ - return `12:00` + if (time === "24:00"){ + return `12:00 am` } if (hours > 12) { return `${hours - 12}:00 pm`; From b54183b7d7c101ea8688693efaf4cb3e63946824 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 14:07:54 +0100 Subject: [PATCH 04/27] addes test for converting midday 12:00 to 12:00 pm --- format-clock-edge-cases/timeConverter.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index cdea1e0b2..5c5362ee3 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -9,7 +9,13 @@ 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 midnight ", function(){ assert.equal(formatAs12HourClock("24:00"), "12:00 am") -}); \ No newline at end of file +}); + +test("can correctly conver midday ", function(){ + assert.equal(formatAs12HourClock("12:00"), "12:00 pm") + +}) \ No newline at end of file From f1bf893c5a73d3f2b358e2278bf56bb7777637c4 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 14:10:50 +0100 Subject: [PATCH 05/27] test failed . fixing the bug. added a code on line 7 that returns 12:00 pm --- format-clock-edge-cases/timeConverter.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index e76d35f4f..f88a3572f 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -4,6 +4,9 @@ function formatAs12HourClock(time) { if (time === "24:00"){ return `12:00 am` } + if(time ==="12:00"){ + return `12:00 pm` + } if (hours > 12) { return `${hours - 12}:00 pm`; } From edf5168223939bdd0ea7e1abad372b1e5a8fe542 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 15:31:59 +0100 Subject: [PATCH 06/27] added a test , to convert time with minute. test failed --- format-clock-edge-cases/timeConverter.js | 6 +++++- format-clock-edge-cases/timeConverter.test.js | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index f88a3572f..b167be57c 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,14 +1,18 @@ function formatAs12HourClock(time) { + const mints = time.slice(-2); const hours = Number(time.slice(0, 2)); if (time === "24:00"){ return `12:00 am` } if(time ==="12:00"){ return `12:00 pm` + } + if(hours=== 12) { + return `${hours}:${mints} pm` } if (hours > 12) { - return `${hours - 12}:00 pm`; + return `${hours - 12}:${mints} pm`; } return `${time} am`; } diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 5c5362ee3..34260b1d5 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -15,7 +15,12 @@ test("can correctly convert midnight ", function(){ assert.equal(formatAs12HourClock("24:00"), "12:00 am") }); -test("can correctly conver midday ", function(){ +test("can correctly convert midday ", function(){ assert.equal(formatAs12HourClock("12:00"), "12:00 pm") +}) + +test("can correctly convert time with minutes ", function(){ + assert.equal( formatAs12HourClock("12:45"), "12:45 pm") + }) \ No newline at end of file From ab3e5faa9732a4af89d76f3433ffbdb6409cff17 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 16:56:14 +0100 Subject: [PATCH 07/27] added a test that coverts time at the end of midnight 00:59. test failed. --- 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 34260b1d5..12fb3596b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -23,4 +23,8 @@ test("can correctly convert midday ", function(){ test("can correctly convert time with minutes ", function(){ assert.equal( formatAs12HourClock("12:45"), "12:45 pm") +}) + +test("can correctly convert time the end of midnight",function(){ +assert.equal(formatAs12HourClock("00:59"),"12:59 am" ) }) \ No newline at end of file From 1d4f08b9ae35fda8724132b7b1672acec6126ebc Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 17:04:06 +0100 Subject: [PATCH 08/27] added a code for converting with min and converting end of midninght --- format-clock-edge-cases/timeConverter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index b167be57c..ba954ff9c 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,5 +1,5 @@ function formatAs12HourClock(time) { - + const stringHours =time.slice(0,2); const mints = time.slice(-2); const hours = Number(time.slice(0, 2)); if (time === "24:00"){ @@ -8,6 +8,10 @@ function formatAs12HourClock(time) { if(time ==="12:00"){ return `12:00 pm` } + if(stringHours == "00"){ + return `12:${mints} am` + + } if(hours=== 12) { return `${hours}:${mints} pm` } From ce0ae5f178965cc8a7a7dc1e66b2ebff1d7ff531 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 17:29:20 +0100 Subject: [PATCH 09/27] just making sure there is no redundancy in the coding --- 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 ba954ff9c..5ccdc6a8c 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -9,7 +9,7 @@ function formatAs12HourClock(time) { return `12:00 pm` } if(stringHours == "00"){ - return `12:${mints} am` + return `12:${mints} am` } if(hours=== 12) { From 8baa8cb70c3805673bda3e60dab7606bce9a4979 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 18:06:31 +0100 Subject: [PATCH 10/27] run prettier for timeConverter.test.js --- format-clock-edge-cases/timeConverter.test.js | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 12fb3596b..d0d7ee6f0 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -1,30 +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:00 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"); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("08:00"), "08:00 am"); }); -test("can correctly convert midnight ", function(){ - - assert.equal(formatAs12HourClock("24:00"), "12:00 am") +test("can correctly convert midnight ", function () { + assert.equal(formatAs12HourClock("24:00"), "12:00 am"); }); -test("can correctly convert midday ", function(){ - assert.equal(formatAs12HourClock("12:00"), "12:00 pm") - -}) - -test("can correctly convert time with minutes ", function(){ - assert.equal( formatAs12HourClock("12:45"), "12:45 pm") +test("can correctly convert midday ", function () { + assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); +}); -}) +test("can correctly convert time with minutes ", function () { + assert.equal(formatAs12HourClock("12:45"), "12:45 pm"); +}); -test("can correctly convert time the end of midnight",function(){ -assert.equal(formatAs12HourClock("00:59"),"12:59 am" ) -}) \ No newline at end of file +test("can correctly convert time the end of midnight", function () { + assert.equal(formatAs12HourClock("00:59"), "12:59 am"); +}); From cdcbc3812836c4c8759e1594b260a92996a604e4 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Sun, 4 Oct 2026 18:07:21 +0100 Subject: [PATCH 11/27] run prettier for timeConverter.js --- format-clock-edge-cases/timeConverter.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 5ccdc6a8c..7762c1771 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,19 +1,18 @@ function formatAs12HourClock(time) { - const stringHours =time.slice(0,2); + const stringHours = time.slice(0, 2); const mints = time.slice(-2); const hours = Number(time.slice(0, 2)); - if (time === "24:00"){ - return `12:00 am` + if (time === "24:00") { + return `12:00 am`; } - if(time ==="12:00"){ - return `12:00 pm` + if (time === "12:00") { + return `12:00 pm`; } - if(stringHours == "00"){ - return `12:${mints} am` - - } - if(hours=== 12) { - return `${hours}:${mints} pm` + if (stringHours == "00") { + return `12:${mints} am`; + } + if (hours === 12) { + return `${hours}:${mints} pm`; } if (hours > 12) { return `${hours - 12}:${mints} pm`; @@ -21,4 +20,4 @@ function formatAs12HourClock(time) { return `${time} am`; } -export {formatAs12HourClock}; +export { formatAs12HourClock }; From 0d2d87c194bcac232570231057b3bd1c20ba48ea Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 11:57:37 +0100 Subject: [PATCH 12/27] changed the input in the function to be 00:00.and made some changes in the program test success. --- 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 d0d7ee6f0..e34b40d72 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -11,7 +11,7 @@ test("can correctly convert morning time", function () { }); test("can correctly convert midnight ", function () { - assert.equal(formatAs12HourClock("24:00"), "12:00 am"); + assert.equal(formatAs12HourClock("00:00"), "12:00 am"); }); test("can correctly convert midday ", function () { From f0c87a6bfdb7a64a5b65552d94cf62159c677110 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 11:58:58 +0100 Subject: [PATCH 13/27] made three lines in comment if the test works with out the three line codes .test was success. --- format-clock-edge-cases/timeConverter.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 7762c1771..9e7f64e37 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -2,9 +2,9 @@ function formatAs12HourClock(time) { const stringHours = time.slice(0, 2); const mints = time.slice(-2); const hours = Number(time.slice(0, 2)); - if (time === "24:00") { - return `12:00 am`; - } + // if (time === "00:00") { + // return `12:00 am`; + //} if (time === "12:00") { return `12:00 pm`; } From 405d9b502c4860e84f08cff757c0f96baa4d3570 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 12:00:24 +0100 Subject: [PATCH 14/27] deleted three lines of code that were in a comment. test is success with out it --- format-clock-edge-cases/timeConverter.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 9e7f64e37..d726d51f7 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -2,9 +2,7 @@ function formatAs12HourClock(time) { const stringHours = time.slice(0, 2); const mints = time.slice(-2); const hours = Number(time.slice(0, 2)); - // if (time === "00:00") { - // return `12:00 am`; - //} + if (time === "12:00") { return `12:00 pm`; } From b1b6c72ae05952aace01d08e0a5938d1dd94e38b Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 12:09:53 +0100 Subject: [PATCH 15/27] changed the return ${mints}to 00, no test failed .kept the line --- 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 d726d51f7..c85edbec9 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -13,7 +13,7 @@ function formatAs12HourClock(time) { return `${hours}:${mints} pm`; } if (hours > 12) { - return `${hours - 12}:${mints} pm`; + return `${hours - 12}:00 pm`; } return `${time} am`; } From b516b5284f09027ac974b22139f4a0e664cc78c2 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 12:21:34 +0100 Subject: [PATCH 16/27] wrote a test for the first begning of noon.test success --- 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 e34b40d72..cb03e8edb 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -25,3 +25,6 @@ test("can correctly convert time with minutes ", function () { test("can correctly convert time the end of midnight", function () { assert.equal(formatAs12HourClock("00:59"), "12:59 am"); }); +test("can correctly convert time at the end of morning", function (){ + assert.equal(formatAs12HourClock("12:01"), "11:59 pm "); +}) \ No newline at end of file From f81b4322b01fcdb985d4db1155479659398b0824 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 12:22:17 +0100 Subject: [PATCH 17/27] fixed some errors on the test for begning of noon --- format-clock-edge-cases/timeConverter.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index cb03e8edb..00b429c6c 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -25,6 +25,6 @@ test("can correctly convert time with minutes ", function () { test("can correctly convert time the end of midnight", function () { assert.equal(formatAs12HourClock("00:59"), "12:59 am"); }); -test("can correctly convert time at the end of morning", function (){ - assert.equal(formatAs12HourClock("12:01"), "11:59 pm "); +test("can correctly convert time at the begning of noon", function (){ + assert.equal(formatAs12HourClock("12:01"), "12:01 pm"); }) \ No newline at end of file From 6a3dca5950b25b065db3b70fd1564db829dd3760 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 12:30:05 +0100 Subject: [PATCH 18/27] put the time===12 line in a comment and run the test and it wa success --- 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 00b429c6c..c7cd5e926 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -27,4 +27,4 @@ test("can correctly convert time the end of midnight", function () { }); test("can correctly convert time at the begning of noon", function (){ assert.equal(formatAs12HourClock("12:01"), "12:01 pm"); -}) \ No newline at end of file +}) From 355ec16d39e963e7d3e7b59aa308c866d7a0e082 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 12:35:00 +0100 Subject: [PATCH 19/27] deleted the commented line of code .because test passed when run without it --- format-clock-edge-cases/timeConverter.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index c85edbec9..ab55a1dc4 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -3,9 +3,6 @@ function formatAs12HourClock(time) { const mints = time.slice(-2); const hours = Number(time.slice(0, 2)); - if (time === "12:00") { - return `12:00 pm`; - } if (stringHours == "00") { return `12:${mints} am`; } From 46fc4ac779be08a6b70fb2fd0131e69b654527fe Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 13:58:51 +0100 Subject: [PATCH 20/27] made the const stringHours on a comments to test run a test .Test was success . --- 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 ab55a1dc4..918191af2 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,9 +1,9 @@ function formatAs12HourClock(time) { - const stringHours = time.slice(0, 2); + //const stringHours = time.slice(0, 2); const mints = time.slice(-2); const hours = Number(time.slice(0, 2)); - if (stringHours == "00") { + if (hours == "00") { return `12:${mints} am`; } if (hours === 12) { From c8ec94b2aa237b225549dabcd31448a6b35a7b98 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 14:00:12 +0100 Subject: [PATCH 21/27] deleted the line i commented and run prettier. --- 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 918191af2..a8a7988f3 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,8 +1,7 @@ function formatAs12HourClock(time) { - //const stringHours = time.slice(0, 2); const mints = time.slice(-2); const hours = Number(time.slice(0, 2)); - + if (hours == "00") { return `12:${mints} am`; } From 90adf7b9d7ecdcd78c7cbe9f2af075f4dc3480d3 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 14:17:56 +0100 Subject: [PATCH 22/27] wrote a test to convert time later than midday with minutes.test failed --- format-clock-edge-cases/timeConverter.test.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index c7cd5e926..e77edc8d8 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -25,6 +25,9 @@ test("can correctly convert time with minutes ", function () { test("can correctly convert time the end of midnight", function () { assert.equal(formatAs12HourClock("00:59"), "12:59 am"); }); -test("can correctly convert time at the begning of noon", function (){ +test("can correctly convert time at the begning of noon", function () { assert.equal(formatAs12HourClock("12:01"), "12:01 pm"); -}) +}); +test("can correctly convert time later than midday",function(){ + assert.equal(formatAs12HourClock("13:01"), "01:01 pm") +}) \ No newline at end of file From 3710e74f08ff7b8293a932ba6bc498e468e0c99f Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 15:04:28 +0100 Subject: [PATCH 23/27] change code based on the test made for 13:00 and greater with min..two testes failed made amend based on that --- format-clock-edge-cases/timeConverter.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index a8a7988f3..41287f603 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -8,8 +8,11 @@ function formatAs12HourClock(time) { if (hours === 12) { return `${hours}:${mints} pm`; } - if (hours > 12) { - return `${hours - 12}:00 pm`; + if (hours > 12 && hours < 22) { + return `0${hours - 12}:${mints} pm`; + } + if(hours>=22){ + return `${hours-12}:${mints} pm`; } return `${time} am`; } From cfb67aeb362cdb4c284d8e63f27d3aaaeb0f8bbc Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 19:30:50 +0100 Subject: [PATCH 24/27] wrote a test to convert the last minute am to pm.test success. --- format-clock-edge-cases/timeConverter.test.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index e77edc8d8..a4bd7db9b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -25,9 +25,12 @@ test("can correctly convert time with minutes ", function () { test("can correctly convert time the end of midnight", function () { assert.equal(formatAs12HourClock("00:59"), "12:59 am"); }); -test("can correctly convert time at the begning of noon", function () { +test("can correctly convert time at the beginning of noon", function () { assert.equal(formatAs12HourClock("12:01"), "12:01 pm"); }); -test("can correctly convert time later than midday",function(){ - assert.equal(formatAs12HourClock("13:01"), "01:01 pm") -}) \ No newline at end of file +test("can correctly convert time later than midday", function () { + assert.equal(formatAs12HourClock("13:01"), "01:01 pm"); +}); +test("can correctly convert time the last minute am turns pm ", function(){ +assert.equal(formatAs12HourClock("11:59"), "11:59 am"); +}); \ No newline at end of file From 934dfc37d6a1af2504f607212f2f36620ab1bf9b Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Mon, 5 Oct 2026 19:55:04 +0100 Subject: [PATCH 25/27] wrote a test that can convert last minute of the day .test success. --- format-clock-edge-cases/timeConverter.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index a4bd7db9b..a82b23b5c 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -33,4 +33,7 @@ test("can correctly convert time later than midday", function () { }); test("can correctly convert time the last minute am turns pm ", function(){ assert.equal(formatAs12HourClock("11:59"), "11:59 am"); -}); \ No newline at end of file +}); +test("can correctly convert time last minute of the day" , function(){ + assert.equal(formatAs12HourClock("23:59"), "11:59 pm"); +}) \ No newline at end of file From cfd5727e2045948f03ecd3e7ca7af168a291a0fc Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Tue, 6 Oct 2026 14:02:30 +0100 Subject: [PATCH 26/27] run prettier and saved --- 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 a82b23b5c..03a5f0ee6 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -31,9 +31,9 @@ test("can correctly convert time at the beginning of noon", function () { test("can correctly convert time later than midday", function () { assert.equal(formatAs12HourClock("13:01"), "01:01 pm"); }); -test("can correctly convert time the last minute am turns pm ", function(){ -assert.equal(formatAs12HourClock("11:59"), "11:59 am"); +test("can correctly convert time the last minute am turns pm ", function () { + assert.equal(formatAs12HourClock("11:59"), "11:59 am"); }); -test("can correctly convert time last minute of the day" , function(){ +test("can correctly convert time last minute of the day", function () { assert.equal(formatAs12HourClock("23:59"), "11:59 pm"); -}) \ No newline at end of file +}); From 8f1d13f986e03b3e1a5ffe7582ab7a3438c2ca41 Mon Sep 17 00:00:00 2001 From: Maharit Belai Date: Tue, 6 Oct 2026 14:02:52 +0100 Subject: [PATCH 27/27] run prettier and saved --- 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 41287f603..ea799c158 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -11,8 +11,8 @@ function formatAs12HourClock(time) { if (hours > 12 && hours < 22) { return `0${hours - 12}:${mints} pm`; } - if(hours>=22){ - return `${hours-12}:${mints} pm`; + if (hours >= 22) { + return `${hours - 12}:${mints} pm`; } return `${time} am`; }