From c53825fed13cf4fbd31c1b7ed7001399fc07da94 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 17 Nov 2024 15:04:38 +0100 Subject: [PATCH] correct padding --- src/routes/index.py | 5 +---- src/utils/misc.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/routes/index.py b/src/routes/index.py index bc83c88..7c12231 100644 --- a/src/routes/index.py +++ b/src/routes/index.py @@ -21,10 +21,7 @@ def index() -> str: def linkify(s): return ".".join(titleify(s).split(".")[:-1]) - def datify(s): - return s[:-14] + " " + s[-4:] - - posts.append((linkify(p), titleify(p), datify(get_post_cdate(p)))) + posts.append((linkify(p), titleify(p), get_post_cdate(p))) return render_template( "index.html", diff --git a/src/utils/misc.py b/src/utils/misc.py index c105d3e..2f30d61 100644 --- a/src/utils/misc.py +++ b/src/utils/misc.py @@ -51,11 +51,17 @@ def get_post(filename: str) -> File | None: return None else: with open(filename, "r") as reader: - return File(reader.read(), get_post_cdate(filename)) + return File(reader.read(), get_post_cdatetime(filename)) + + +def get_post_cdatetime(filename: str) -> str: + return ctime(os_path.getmtime(filename)) def get_post_cdate(filename: str) -> str: - return ctime(os_path.getmtime(filename)) + dt = datetime.fromtimestamp(os_path.getmtime(filename)) + + return dt.strftime("%a %b %d %Y") def delete_post(filename: str) -> bool: