Skip to content

Use timezone-aware ISO 8601 for website timestamp #13347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
15 changes: 14 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,20 @@
# (Sphinx looks at variable changes and rewrites all files if some change)
copyright = ( # noqa: A001
f'2012–{td.year}, MNE Developers. Last updated <time datetime="{td.isoformat()}" class="localized">{td.strftime("%Y-%m-%d %H:%M %Z")}</time>\n' # noqa: E501
'<script type="text/javascript">function formatTimestamp() {document.querySelectorAll("time.localized").forEach(el => el.textContent = new Date(el.getAttribute("datetime")).toLocaleString([], {dateStyle: "medium", timeStyle: "long"}));};if (document.readyState != "loading") formatTimestamp();else document.addEventListener("DOMContentLoaded", formatTimestamp);</script>' # noqa: E501
"""<script type="text/javascript">
function formatTimestamp() {
document.querySelectorAll("time.localized").forEach(el => {
const d = new Date(el.getAttribute("datetime"));
const locale = Intl.DateTimeFormat().resolvedOptions().locale;
el.textContent = d.toLocaleString(locale);
});
}
if (document.readyState !== "loading") {
formatTimestamp();
} else {
document.addEventListener("DOMContentLoaded", formatTimestamp);
}
</script>"""
)
if os.getenv("MNE_FULL_DATE", "false").lower() != "true":
copyright = f"2012–{td.year}, MNE Developers. Last updated locally." # noqa: A001
Expand Down
Loading