20250408.1744116663
This commit is contained in:
parent
582a9f1380
commit
2ab53d7a93
1 changed files with 13 additions and 6 deletions
|
@ -20,11 +20,13 @@ import time
|
|||
import urllib.parse
|
||||
import urllib.request
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
DB_NAME = Path("metadata.db")
|
||||
TZ = 1
|
||||
# TZ = 1
|
||||
TZ = ZoneInfo("Europe/Warsaw")
|
||||
TOOLS = ("jrnl", "sqlite3")
|
||||
FILES = (".jpeg", ".jpg", ".png", ".gif")
|
||||
FILES_PATH = Path("attachments")
|
||||
|
@ -87,7 +89,9 @@ def get_diary_path_by_name(name: str):
|
|||
def make_tz_unixtime(target_time: str):
|
||||
return int(
|
||||
(
|
||||
datetime.strptime(target_time, "%Y-%m-%dT%H:%M:%SZ") + timedelta(hours=TZ)
|
||||
datetime.strptime(target_time, "%Y-%m-%dT%H:%M:%SZ")
|
||||
.replace(tzinfo=ZoneInfo("UTC"))
|
||||
.astimezone(TZ)
|
||||
).timestamp()
|
||||
)
|
||||
|
||||
|
@ -102,8 +106,11 @@ def find_closest_entry(data, target_timestamp: int):
|
|||
|
||||
def convert_diary_date(date_str):
|
||||
try:
|
||||
dt = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%SZ") + timedelta(hours=TZ)
|
||||
return dt.strftime("%d %b %Y at %H:%M:%S:")
|
||||
return (
|
||||
datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%SZ")
|
||||
.replace(tzinfo=ZoneInfo("UTC"))
|
||||
.astimezone(TZ)
|
||||
).strftime("%d %b %Y at %H:%M:%S:")
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
@ -408,7 +415,7 @@ def doctor():
|
|||
if check_diary:
|
||||
|
||||
def check_jrnl(metadata: list):
|
||||
dt = datetime.fromtimestamp(metadata[1], tz=timezone(timedelta(hours=TZ)))
|
||||
dt = datetime.fromtimestamp(metadata[1], tz=TZ)
|
||||
diary_datetime = dt.strftime("%Y/%m/%d at %I:%M:%S %p")
|
||||
try:
|
||||
result = subprocess.run(
|
||||
|
|
Loading…
Add table
Reference in a new issue