Skip to content

Commit

Permalink
Improved the access date javascript code
Browse files Browse the repository at this point in the history
  • Loading branch information
benji-glitsos-ga committed Mar 26, 2024
1 parent 719d25d commit d92b8c3
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions docs/_static/scripts/citation-access-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ document.addEventListener("DOMContentLoaded", function (event) {
.getElementById("paper-citation")
.querySelector("pre");

const today = new Date();
const todayInternationalFormat = (() => {
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
return `${year}-${month}-${day}`;
})();

const year = today.getFullYear();
const month = today.getMonth() + 1; // Months are zero-based, so we add 1
const day = today.getDate();

const scientificDate =
year +
"-" +
month.toString().padStart(2, "0") +
"-" +
day.toString().padStart(2, "0");

dataCitation.textContent += " Accessed: " + scientificDate;
dataCitation.textContent += " Accessed: " + todayInternationalFormat;
});

0 comments on commit d92b8c3

Please sign in to comment.