From 7553028f2dfdfc123dd5b98a3ab587913896db2d Mon Sep 17 00:00:00 2001 From: Piotr Gaczkowski Date: Sun, 3 May 2026 18:39:04 +0200 Subject: [PATCH] feat: Now more timezone aware than ever --- devenv.nix | 2 ++ pyproject.toml | 1 + src/kronos/mobilizon.py | 12 ++++--- src/typst/assets/calendar.svg | 20 +++++------ src/typst/calendar.typ | 66 ++++++++++++++++++++--------------- src/typst/event.typ | 24 ++++++++----- 6 files changed, 73 insertions(+), 52 deletions(-) diff --git a/devenv.nix b/devenv.nix index b96c8d3..85e5426 100644 --- a/devenv.nix +++ b/devenv.nix @@ -24,7 +24,9 @@ }; packages = [ + pkgs.google-fonts pkgs.hanken-grotesk + pkgs.typstyle pkgs.uv ]; diff --git a/pyproject.toml b/pyproject.toml index 7530a28..ec68b5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,7 @@ dependencies = [ "premailer==3.10.0", "python-dateutil==2.9.0.post0", "python-dotenv==1.1.1", + "pytz==2026.1.post1", "requests==2.32.4", "six==1.17.0", "soupsieve==2.7", diff --git a/src/kronos/mobilizon.py b/src/kronos/mobilizon.py index 25c74c1..9881c09 100644 --- a/src/kronos/mobilizon.py +++ b/src/kronos/mobilizon.py @@ -5,6 +5,7 @@ import sys import requests from bs4 import BeautifulSoup +from pytz import timezone MOBILIZON_API_URL = "https://events.hs3.pl/api" QUERY_LIMIT = 100 @@ -122,12 +123,15 @@ def get_raw_events(): ev["txt_description"] = BeautifulSoup(ev["description"], "html.parser").get_text() - begins = ev["beginsOn"].split("T") - ends = ev["endsOn"].split("T") - txt_date = f"{begins[0]} {begins[1][:-4]}-" + local_tz = timezone("Europe/Warsaw") + begins_date = datetime.datetime.fromisoformat(ev["beginsOn"]).astimezone(local_tz) + ends_date = datetime.datetime.fromisoformat(ev["endsOn"]).astimezone(local_tz) + begins = (begins_date.strftime("%Y-%m-%d"), begins_date.strftime("%H:%M")) + ends = (ends_date.strftime("%Y-%m-%d"), ends_date.strftime("%H:%M")) + txt_date = f"{begins[0]} {begins[1]}-" if begins[0] != ends[0]: txt_date += f"{ends[0]}" - txt_date += f"{ends[1][:-4]}" + txt_date += f"{ends[1]}" ev["txt_date"] = txt_date extract_picture(ev) diff --git a/src/typst/assets/calendar.svg b/src/typst/assets/calendar.svg index 7c6b5d6..69b9967 100644 --- a/src/typst/assets/calendar.svg +++ b/src/typst/assets/calendar.svg @@ -7,7 +7,7 @@ width="1122.52" height="1587.4" viewBox="0 0 1122.52 1587.4" - sodipodi:docname="PLAKAT_01 do svg.svg" + sodipodi:docname="PLAKAT_01 do svg_20260503.svg" inkscape:version="1.2.2 (732a01da63, 2022-12-09)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -178,7 +178,7 @@ inkscape:window-x="2869" inkscape:window-y="1609" inkscape:window-maximized="1" - inkscape:current-layer="g19"> + inkscape:current-layer="g17"> @@ -25096,7 +25096,7 @@ id="g14267"> DOŁĄCZ DO NAS @@ -25134,7 +25134,7 @@ id="g14291"> hs 3 .