From 7fe61328b577f2b4705b350821c5e951fca99697 Mon Sep 17 00:00:00 2001 From: Michael Genson <71845777+michael-genson@users.noreply.github.com> Date: Thu, 4 Jul 2024 19:01:03 +0000 Subject: [PATCH] make hour_only_tz work for any timezone --- mealie/schema/_mealie/mealie_model.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mealie/schema/_mealie/mealie_model.py b/mealie/schema/_mealie/mealie_model.py index d46ed11849f..62ff5d3d2ad 100644 --- a/mealie/schema/_mealie/mealie_model.py +++ b/mealie/schema/_mealie/mealie_model.py @@ -1,5 +1,6 @@ from __future__ import annotations +import re from collections.abc import Sequence from datetime import datetime, timezone from enum import Enum @@ -16,6 +17,8 @@ T = TypeVar("T", bound=BaseModel) +HOUR_ONLY_TZ_PATTERN = re.compile(r"[+-]\d{2}$") + class SearchType(Enum): fuzzy = "fuzzy" @@ -49,8 +52,7 @@ def fix_hour_only_tz(cls, data: T) -> T: continue except AttributeError: continue - # this only works for UTC, but we enforce UTC throughout the entire application - if val.endswith("+00"): + if re.search(HOUR_ONLY_TZ_PATTERN, val): setattr(data, field, val + ":00") return data