From ae73566028e6251c09c1d73477ad9cfdf80f8f65 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Fri, 2 Oct 2026 09:49:15 +0100 Subject: [PATCH 01/12] add Prep/ directory to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bde36e5302..61d65272ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules .DS_Store .vscode -**/.DS_Store \ No newline at end of file +**/.DS_Store +Prep/ \ No newline at end of file From 62033c78a3028bc1489e9ef3e3cf1831ff5749a5 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 3 Oct 2026 16:15:52 +0100 Subject: [PATCH 02/12] timeConverter.js fix edge cases for hours ,and put minutes for input in 12-hour clock conversion --- format-clock-edge-cases/timeConverter.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 310c07bd9c..82e6a2a6c2 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,11 +1,22 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); + const minutes = time.slice(-2); - if (hours > 12) { - return `${hours - 12}:00 pm`; + if (hours > 22) { + return `${hours - 12}:${minutes} pm`; } - return `${time} am`; + else if (hours > 12) { + return `${hours - 12}:${minutes} pm`; + } + else if (hours > 9){ + return `${hours}:${minutes} am` + } +else if (hours < 1) { + return `12:${minutes} am`; +} + return `${hours}:${minutes} am`; } + export {formatAs12HourClock}; From bcf5419ff012b8f2400ce94cc54d6a102334467b Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 3 Oct 2026 16:34:03 +0100 Subject: [PATCH 03/12] fix return for hours input 01to09 as `0${hours}:${minutes} am`; --- 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 82e6a2a6c2..58dbf8a760 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -15,7 +15,7 @@ function formatAs12HourClock(time) { else if (hours < 1) { return `12:${minutes} am`; } - return `${hours}:${minutes} am`; + return `0${hours}:${minutes} am`; } From 8b179f75f56248bee3640e21265c84bde9f7b81a Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 3 Oct 2026 17:34:45 +0100 Subject: [PATCH 04/12] timeConverter.js fixed single hour time pm formats; added edge cases hour === 12 for noon --- 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 58dbf8a760..7f9264a016 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -9,13 +9,17 @@ function formatAs12HourClock(time) { else if (hours > 12) { return `${hours - 12}:${minutes} pm`; } + else if (hours === 12) { + return `12:${minutes} pm`; + } + else if (hours > 9){ return `${hours}:${minutes} am` } else if (hours < 1) { return `12:${minutes} am`; } - return `0${hours}:${minutes} am`; + return `${hours}:${minutes} am`; } From f6b1388a00b252c28dc1b7fd3eb3e4f42df8cd3d Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sat, 3 Oct 2026 17:35:52 +0100 Subject: [PATCH 05/12] test.js added five extra tests namely midnight, single hour morning, due characters morning, noon time, and shows minutes --- format-clock-edge-cases/timeConverter.test.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 88f2af0948..f5e155afdd 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -7,5 +7,25 @@ test("correctly convert time after 12:00", function(){ }); test("can correctly convert morning time", function() { - assert.equal(formatAs12HourClock("08:00"), "08:00 am"); + assert.equal(formatAs12HourClock("08:00"), "8:00 am"); }); + +test("can correctly convert midnight time", function() { + assert.equal(formatAs12HourClock("00:00"), "12:00 am"); +}); + +test("can correctly convert single character hour morning time", function() { + assert.equal(formatAs12HourClock("09:00"), "9:00 am"); +}); + +test("can correctly convert dual characters hour morning time", function() { + assert.equal(formatAs12HourClock("11:00"), "11:00 am"); +}); + +test("can correctly convert noon time", function() { + assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); +}); + +test("can correctly shows minutes input", function() { + assert.equal(formatAs12HourClock("16:59"), "4:59 pm"); +}); \ No newline at end of file From 8255bd2b5f93a75123cea549a9a5ad4d0eacd626 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 4 Oct 2026 08:53:14 +0100 Subject: [PATCH 06/12] timeConverter.js to simplify hour formatting logic for hours > 12 --- format-clock-edge-cases/timeConverter.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 7f9264a016..5030bea599 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -1,26 +1,17 @@ function formatAs12HourClock(time) { - const hours = Number(time.slice(0, 2)); const minutes = time.slice(-2); - if (hours > 22) { - return `${hours - 12}:${minutes} pm`; - } - else if (hours > 12) { + if (hours > 12) { return `${hours - 12}:${minutes} pm`; - } - else if (hours === 12) { + } else if (hours === 12) { return `12:${minutes} pm`; + } else if (hours > 9) { + return `${hours}:${minutes} am`; + } else if (hours < 1) { + return `12:${minutes} am`; } - - else if (hours > 9){ - return `${hours}:${minutes} am` - } -else if (hours < 1) { - return `12:${minutes} am`; -} return `${hours}:${minutes} am`; } - -export {formatAs12HourClock}; +export { formatAs12HourClock }; From fee5fba4f47b3dfd63b9e3528b6f09618e8556a7 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Sun, 4 Oct 2026 08:54:34 +0100 Subject: [PATCH 07/12] line ending convention change from CRLF to LF for both coursework files --- format-clock-edge-cases/timeConverter.test.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index f5e155afdd..32a6d83f5a 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -1,31 +1,31 @@ -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"), "8:00 am"); +test("can correctly convert morning time", function () { + assert.equal(formatAs12HourClock("08:00"), "8:00 am"); }); -test("can correctly convert midnight 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"); }); -test("can correctly convert single character hour morning time", function() { - assert.equal(formatAs12HourClock("09:00"), "9:00 am"); +test("can correctly convert single character hour morning time", function () { + assert.equal(formatAs12HourClock("09:00"), "9:00 am"); }); -test("can correctly convert dual characters hour morning time", function() { - assert.equal(formatAs12HourClock("11:00"), "11:00 am"); +test("can correctly convert dual characters hour morning time", function () { + assert.equal(formatAs12HourClock("11:00"), "11:00 am"); }); -test("can correctly convert noon time", function() { - assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); +test("can correctly convert noon time", function () { + assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); }); -test("can correctly shows minutes input", function() { - assert.equal(formatAs12HourClock("16:59"), "4:59 pm"); -}); \ No newline at end of file +test("can correctly shows minutes input", function () { + assert.equal(formatAs12HourClock("16:59"), "4:59 pm"); +}); From dcf5d9f75945e904a4871caf86f8c01d099813fe Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 5 Oct 2026 11:33:47 +0100 Subject: [PATCH 08/12] fix: standardize hour formatting for morning times in tests --- 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 32a6d83f5a..30bc237742 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -7,7 +7,7 @@ test("correctly convert time after 12:00", function () { }); test("can correctly convert morning time", function () { - assert.equal(formatAs12HourClock("08:00"), "8:00 am"); + assert.equal(formatAs12HourClock("08:00"), "08:00 am"); }); test("can correctly convert midnight time", function () { @@ -15,7 +15,7 @@ test("can correctly convert midnight time", function () { }); test("can correctly convert single character hour morning time", function () { - assert.equal(formatAs12HourClock("09:00"), "9:00 am"); + assert.equal(formatAs12HourClock("09:00"), "09:00 am"); }); test("can correctly convert dual characters hour morning time", function () { From b350b5409b5496c8cd1b5a7f6a0b8e2a5628de51 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 5 Oct 2026 12:07:47 +0100 Subject: [PATCH 09/12] timeConverter.js fix: adjust hour formatting logic for times greater than 21, to line up with expect time formatting in test file. --- format-clock-edge-cases/timeConverter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.js b/format-clock-edge-cases/timeConverter.js index 5030bea599..e5b3dc8f4d 100644 --- a/format-clock-edge-cases/timeConverter.js +++ b/format-clock-edge-cases/timeConverter.js @@ -2,8 +2,10 @@ function formatAs12HourClock(time) { const hours = Number(time.slice(0, 2)); const minutes = time.slice(-2); - if (hours > 12) { + if (hours > 21) { return `${hours - 12}:${minutes} pm`; + } else if (hours > 12) { + return `0${hours - 12}:${minutes} pm`; } else if (hours === 12) { return `12:${minutes} pm`; } else if (hours > 9) { @@ -11,7 +13,7 @@ function formatAs12HourClock(time) { } else if (hours < 1) { return `12:${minutes} am`; } - return `${hours}:${minutes} am`; + return `0${hours}:${minutes} am`; } export { formatAs12HourClock }; From c4cfbd32170df42d335104add4a2dec5c65baff3 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 5 Oct 2026 12:08:01 +0100 Subject: [PATCH 10/12] test: add cases for afternoon and last minute time conversions --- format-clock-edge-cases/timeConverter.test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 30bc237742..1810779d33 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -26,6 +26,18 @@ test("can correctly convert noon time", function () { assert.equal(formatAs12HourClock("12:00"), "12:00 pm"); }); +test("can correctly convert to single character afternoon time", function () { + assert.equal(formatAs12HourClock("16:59"), "04:59 pm"); +}); + test("can correctly shows minutes input", function () { - assert.equal(formatAs12HourClock("16:59"), "4:59 pm"); + assert.equal(formatAs12HourClock("16:59"), "04:59 pm"); +}); + +test("can correctly keep am in last minute of morning", function () { + assert.equal(formatAs12HourClock("11:59"), "11:59 am"); +}); + +test("can correctly keep pm in last minute of the day", function () { + assert.equal(formatAs12HourClock("23:59"), "11:59 pm"); }); From 7eb6e6505360330155f7081a44dde16788ca8c24 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 5 Oct 2026 12:09:23 +0100 Subject: [PATCH 11/12] fix: remove redundant entry for Prep/ from .gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 61d65272ed..bde36e5302 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ node_modules .DS_Store .vscode -**/.DS_Store -Prep/ \ No newline at end of file +**/.DS_Store \ No newline at end of file From a08f8d8901a3524be93bc106d56348ae46233a63 Mon Sep 17 00:00:00 2001 From: AlanGit-debug2604 Date: Mon, 5 Oct 2026 21:01:00 +0100 Subject: [PATCH 12/12] test: correct afternoon time conversion and add additional test cases for edge times --- format-clock-edge-cases/timeConverter.test.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/format-clock-edge-cases/timeConverter.test.js b/format-clock-edge-cases/timeConverter.test.js index 1810779d33..79abad270b 100644 --- a/format-clock-edge-cases/timeConverter.test.js +++ b/format-clock-edge-cases/timeConverter.test.js @@ -27,11 +27,15 @@ test("can correctly convert noon time", function () { }); test("can correctly convert to single character afternoon time", function () { - assert.equal(formatAs12HourClock("16:59"), "04:59 pm"); + assert.equal(formatAs12HourClock("16:00"), "04:00 pm"); +}); + +test("can correctly keep pm in first hour after noon", function () { + assert.equal(formatAs12HourClock("13:00"), "01:00 pm"); }); test("can correctly shows minutes input", function () { - assert.equal(formatAs12HourClock("16:59"), "04:59 pm"); + assert.equal(formatAs12HourClock("13:30"), "01:30 pm"); }); test("can correctly keep am in last minute of morning", function () { @@ -41,3 +45,11 @@ test("can correctly keep am in last minute of morning", function () { test("can correctly keep pm in last minute of the day", function () { assert.equal(formatAs12HourClock("23:59"), "11:59 pm"); }); + +test("can correctly keep am in first minute of the day", function () { + assert.equal(formatAs12HourClock("00:01"), "12:01 am"); +}); + +test("can correctly keep pm in first minute after noon", function () { + assert.equal(formatAs12HourClock("12:01"), "12:01 pm"); +});