Skip to content

Commit 94d9871

Browse files
cbrnrdrammock
andauthored
Use timezone-aware ISO 8601 for website timestamp (mne-tools#13347)
Co-authored-by: Daniel McCloy <[email protected]>
1 parent 06d09de commit 94d9871

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

doc/conf.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,24 @@
6262

6363
# We need to triage which date type we use so that incremental builds work
6464
# (Sphinx looks at variable changes and rewrites all files if some change)
65-
copyright = ( # noqa: A001
66-
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
67-
'<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
65+
project_copyright = (
66+
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
67+
"""<script type="text/javascript">
68+
function formatTimestamp() {
69+
document.querySelectorAll("time.localized").forEach(el => {
70+
const d = new Date(el.getAttribute("datetime"));
71+
el.textContent = d.toLocaleString("sv-SE", { "timeZoneName": "short" });
72+
});
73+
}
74+
if (document.readyState !== "loading") {
75+
formatTimestamp();
76+
} else {
77+
document.addEventListener("DOMContentLoaded", formatTimestamp);
78+
}
79+
</script>"""
6880
)
6981
if os.getenv("MNE_FULL_DATE", "false").lower() != "true":
70-
copyright = f"2012–{td.year}, MNE Developers. Last updated locally." # noqa: A001
82+
project_copyright = f"2012–{td.year}, MNE Developers. Last updated locally."
7183

7284
# The version info for the project you're documenting, acts as replacement for
7385
# |version| and |release|, also used in various other places throughout the

0 commit comments

Comments
 (0)