From f4bbeea8251c9238a97e2644d9a857be5b73a1c8 Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Wed, 8 May 2024 18:27:32 +1000 Subject: [PATCH] Fix time --- slices/main/assets/js/app.ts | 5 +++-- slices/main/views/site/home.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/slices/main/assets/js/app.ts b/slices/main/assets/js/app.ts index 8509ed1..d0598c1 100644 --- a/slices/main/assets/js/app.ts +++ b/slices/main/assets/js/app.ts @@ -17,17 +17,18 @@ import { md_gallery } from "./gallery.js"; const homeTime = document.querySelector(".home-time"); if (homeTime != undefined) { setInterval(() => { - const [hours, minutes, seconds] = homeTime.innerHTML + let [hours, minutes, seconds] = homeTime.innerHTML .split(" ")[0] .split(":") .map((x) => parseInt(x, 10)); + const ampm = homeTime.innerHTML.split(" ")[1]; const time = new Date(); + hours = ampm == "AM" ? hours : hours + 12; time.setHours(hours, minutes, seconds); const nextTime = time.valueOf() + 1000; homeTime.innerHTML = formatAMPM(new Date(nextTime)); }, 1000); - console.log(); } function formatAMPM(date) { diff --git a/slices/main/views/site/home.rb b/slices/main/views/site/home.rb index 8d1c479..f33e1bf 100644 --- a/slices/main/views/site/home.rb +++ b/slices/main/views/site/home.rb @@ -19,7 +19,7 @@ module Main end expose :time do |date| - date.strftime("%H:%M:%S %p") + date.strftime("%I:%M:%S %p") end expose :week_posts do