feat: authoritative plugin fields

Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
jokob-sk
2026-01-24 16:19:27 +11:00
parent 49e689f022
commit be381488aa
10 changed files with 477 additions and 595 deletions

View File

@@ -156,14 +156,21 @@ def parse_datetime(dt_str):
def format_date(date_str: str) -> str:
try:
if isinstance(date_str, str):
# collapse all whitespace into single spaces
date_str = re.sub(r"\s+", " ", date_str.strip())
dt = parse_datetime(date_str)
if not dt:
return f"invalid:{repr(date_str)}"
if dt.tzinfo is None:
# Set timezone if missing — change to timezone.utc if you prefer UTC
now = datetime.datetime.now(conf.tz)
dt = dt.replace(tzinfo=now.astimezone().tzinfo)
dt = dt.replace(tzinfo=conf.tz)
return dt.astimezone().isoformat()
except (ValueError, AttributeError, TypeError):
return "invalid"
except Exception:
return f"invalid:{repr(date_str)}"
def format_date_diff(date1, date2, tz_name):