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.parse
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from zoneinfo import ZoneInfo
|
||||||
|
|
||||||
DB_NAME = Path("metadata.db")
|
DB_NAME = Path("metadata.db")
|
||||||
TZ = 1
|
# TZ = 1
|
||||||
|
TZ = ZoneInfo("Europe/Warsaw")
|
||||||
TOOLS = ("jrnl", "sqlite3")
|
TOOLS = ("jrnl", "sqlite3")
|
||||||
FILES = (".jpeg", ".jpg", ".png", ".gif")
|
FILES = (".jpeg", ".jpg", ".png", ".gif")
|
||||||
FILES_PATH = Path("attachments")
|
FILES_PATH = Path("attachments")
|
||||||
|
@ -87,7 +89,9 @@ def get_diary_path_by_name(name: str):
|
||||||
def make_tz_unixtime(target_time: str):
|
def make_tz_unixtime(target_time: str):
|
||||||
return int(
|
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()
|
).timestamp()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -102,8 +106,11 @@ def find_closest_entry(data, target_timestamp: int):
|
||||||
|
|
||||||
def convert_diary_date(date_str):
|
def convert_diary_date(date_str):
|
||||||
try:
|
try:
|
||||||
dt = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%SZ") + timedelta(hours=TZ)
|
return (
|
||||||
return dt.strftime("%d %b %Y at %H:%M:%S:")
|
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:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -408,7 +415,7 @@ def doctor():
|
||||||
if check_diary:
|
if check_diary:
|
||||||
|
|
||||||
def check_jrnl(metadata: list):
|
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")
|
diary_datetime = dt.strftime("%Y/%m/%d at %I:%M:%S %p")
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
|
|
Loading…
Add table
Reference in a new issue