Skip to content

Commit

Permalink
fix the midnight time bug and update the version information
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnagda1 committed Oct 20, 2023
1 parent a39e1ce commit 1d42f73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
28 changes: 19 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -316,34 +316,44 @@ <h1>रात का चौघड़िया</h1>
{ 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");
Expand All @@ -352,7 +362,7 @@ <h1>रात का चौघड़िया</h1>
console.error("Element not found for ID: " + getCellID());
}
}, 1000);
</script>
</script>
</body>

</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 1d42f73

Please sign in to comment.