Compare commits

...

2 commits

Author SHA1 Message Date
080f023835
correctly fix time_now
All checks were successful
Publish latest version / build (push) Successful in 33s
2024-11-17 17:20:05 +01:00
8536895997
for testing, use same tz as the docker image 2024-11-17 17:14:03 +01:00
2 changed files with 8 additions and 4 deletions

View file

@ -26,5 +26,5 @@ for example, using `pass` password:
```sh ```sh
$ pip install -r requirements.txt $ pip install -r requirements.txt
$ TD_USERPASS=pass FLASK_APP=src/app flask run $ TD_USERPASS=pass TZ=UTC FLASK_APP=src/app flask run
``` ```

View file

@ -1,4 +1,4 @@
from datetime import datetime from datetime import UTC, datetime
from os import listdir, utime from os import listdir, utime
from os import path as os_path from os import path as os_path
from os import remove as os_remove from os import remove as os_remove
@ -98,8 +98,12 @@ 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 without being timezone aware"""
return datetime.now(timezone(session[Config._session_timezone])).timestamp() now = datetime.now(UTC).replace(tzinfo=None)
return (
now.timestamp()
+ timezone(session[Config._session_timezone]).utcoffset(now).total_seconds()
)
def create_post(file_id: int, content: str) -> bool: def create_post(file_id: int, content: str) -> bool: