Skip to content

Commit

Permalink
fix: update date formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sameemul-haque committed Apr 16, 2024
1 parent 9847200 commit 862ee68
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ document.addEventListener("DOMContentLoaded", function () {
if (!square.classList.contains("previous-year")) {
square.addEventListener("click", function () {
const currentLevel = parseInt(square.getAttribute("data-level"));
const options = { year: "numeric", month: "short", day: "numeric" };
console.log(new Date(square.getAttribute("data-date")).toLocaleDateString("en", options));
increaseLevel(square, currentLevel);
});

Expand All @@ -60,7 +62,8 @@ document.addEventListener("DOMContentLoaded", function () {
const target = event.target;
if (target && target.matches("li[data-date]")) {
const date = target.getAttribute("data-date");
target.title = new Date(date).toLocaleDateString();
const options = { year: "numeric", month: "long", day: "numeric" };
target.title = new Date(date).toLocaleDateString("en", options);
}
});
}
Expand Down

0 comments on commit 862ee68

Please sign in to comment.