Skip to content

Commit 04f544f

Browse files
author
russom
committed
Restore files unrelated to this PR
1 parent fcf27e7 commit 04f544f

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function formatAs12HourClock(time) {
2+
3+
const hours = Number(time.slice(0, 2));
4+
5+
if (hours > 12) {
6+
return `${hours - 12}:00 pm`;
7+
}
8+
return `${time} am`;
9+
}
10+
11+
export {formatAs12HourClock};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {formatAs12HourClock} from "./timeConverter.js";
2+
import assert from "node:assert";
3+
import test from "node:test";
4+
5+
test("correctly convert time after 12:00", function(){
6+
assert.equal(formatAs12HourClock("23:00"), "11:00 pm");
7+
});
8+
9+
test("can correctly convert morning time", function() {
10+
assert.equal(formatAs12HourClock("08:00"), "08:00 am");
11+
});

0 commit comments

Comments
 (0)