Skip to content

Commit

Permalink
fix(docs): improve last modified date formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
TheManchineel committed Dec 14, 2024
1 parent 890567f commit 71a9f8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion build_docs_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def build_docs_and_index():
with StringIO() as index_entries:
for path in sorted(pathlib.Path("/workspace").rglob("*/*.md")):
print(f"Adding {path} to the build queue")
last_modified = datetime.datetime.fromtimestamp(path.stat().st_mtime).strftime("%Y-%m-%d %H:%M:%S")
last_modified_time = datetime.datetime.fromtimestamp(path.stat().st_mtime)
last_modified_time.microsecond = 0
if last_modified_time.tzinfo is None:
last_modified_time = last_modified_time.replace(tzinfo=datetime.timezone.utc)
last_modified = last_modified_time.isoformat()
output_filename = path.parent / f"{path.stem}.html"
if output_filename.name == "index.html":
index_entries.write(
Expand Down
7 changes: 6 additions & 1 deletion template.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ <h2>Indice</h2>

<div class="container">
$if(date)$
<em>Ultima modifica: </em> $date$
<em>Ultima modifica: </em>
<script>
// date is in "YYYY-MM-DD HH:MM:SSZ" format, UTC timezone
let date = new Date("$date$");
document.write(date.toLocaleString());
</script>
$endif$
</div>

Expand Down

0 comments on commit 71a9f8b

Please sign in to comment.