From 1d42f73309d12f70f093fbbf3640934071afa12c Mon Sep 17 00:00:00 2001 From: Vishal Nagda Date: Fri, 20 Oct 2023 08:35:04 +0530 Subject: [PATCH] fix the midnight time bug and update the version information --- index.html | 28 +++++++++++++++++++--------- package.json | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index be113e2..921f685 100644 --- a/index.html +++ b/index.html @@ -316,34 +316,44 @@

रात का चौघड़िया

{ start: "04:30", end: "06:00", prefix: "430-559" }, ]; + // Function to get the current cell ID based on the time function getCellID() { const date = new Date(); const hh = (date.getHours() < 10 ? "0" : "") + date.getHours(); const mm = (date.getMinutes() < 10 ? "0" : "") + date.getMinutes(); const hhmm = hh + ":" + mm; - + const currentDay = date.getDay(); - + let previousDay = currentDay - 1; + + if (previousDay === -1) { + previousDay = 6; // Set to Saturday if it's currently Sunday + } + // Determine whether it's day or night const timeRanges = date.getHours() >= 6 && date.getHours() < 18 ? dayTimeRanges : nightTimeRanges; - + for (const range of timeRanges) { if (hhmm >= range.start && hhmm < range.end) { - return range.prefix + "-" + currentDay; + if (hhmm >= "00:00" && hhmm < "06:00") { + return range.prefix + "-" + previousDay; + } else { + return range.prefix + "-" + currentDay; + } } } - + console.error("Time error - " + date); alert("Invalid time. Please report an issue with this time - " + date); } - + let old; - + setInterval(function () { if (old) { old.classList.remove("current-status"); } - + const doc = document.getElementById(getCellID()); if (doc) { doc.classList.add("current-status"); @@ -352,7 +362,7 @@

रात का चौघड़िया

console.error("Element not found for ID: " + getCellID()); } }, 1000); - + \ No newline at end of file diff --git a/package.json b/package.json index 14cb7e5..850d4b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chaughadiya", - "version": "2.0.0", + "version": "2.1.0", "description": "This application is based on astrology, and shows the status of current time based on astrological view.", "main": "index.js", "scripts": {