Compare commits
2 commits
608e85bc93
...
c53825fed1
Author | SHA1 | Date | |
---|---|---|---|
c53825fed1 | |||
68c2886ac0 |
2 changed files with 10 additions and 7 deletions
|
@ -21,10 +21,7 @@ def index() -> str:
|
||||||
def linkify(s):
|
def linkify(s):
|
||||||
return ".".join(titleify(s).split(".")[:-1])
|
return ".".join(titleify(s).split(".")[:-1])
|
||||||
|
|
||||||
def datify(s):
|
posts.append((linkify(p), titleify(p), get_post_cdate(p)))
|
||||||
return s[:-14] + " " + s[-4:]
|
|
||||||
|
|
||||||
posts.append((linkify(p), titleify(p), datify(get_post_cdate(p))))
|
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"index.html",
|
"index.html",
|
||||||
|
|
|
@ -51,11 +51,17 @@ def get_post(filename: str) -> File | None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
with open(filename, "r") as reader:
|
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:
|
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:
|
def delete_post(filename: str) -> bool:
|
||||||
|
@ -93,7 +99,7 @@ def exist_post(file_id: int) -> float | None:
|
||||||
|
|
||||||
def time_now() -> float:
|
def time_now() -> float:
|
||||||
"""get current time based on timezone"""
|
"""get current time based on timezone"""
|
||||||
now = datetime.utcnow()
|
now = datetime.now(datetime.timezone.utc)
|
||||||
return (
|
return (
|
||||||
now.timestamp()
|
now.timestamp()
|
||||||
+ timezone(session[Config._session_timezone]).utcoffset(now).total_seconds()
|
+ timezone(session[Config._session_timezone]).utcoffset(now).total_seconds()
|
||||||
|
|
Loading…
Reference in a new issue