fix: normalize datetimes to aware UTC in dedup

Dedup with precision=datetime crashed with TypeError: redminelib returns
naive created_on/updated_on while the cutoff from _compute_dedup_cutoff
is aware UTC. Normalize at a single point: _parse_datetime now always
returns an aware datetime (naive treated as UTC), matching its docstring.
The dedup cutoff is normalized the same way, and any residual comparison
TypeError is wrapped in RedmineAPIError instead of leaking raw.

Also fix --commit saving last_used.to as naive local time; it now stores
aware UTC (datetime.now(timezone.utc)) so the next run computes a correct
aware cutoff.

Closes #58
This commit is contained in:
Кокос Артем Николаевич
2026-07-17 12:11:35 +07:00
parent c4ec23048a
commit 46674ba926
4 changed files with 164 additions and 22 deletions

View File

@@ -528,9 +528,9 @@ def main(argv: Optional[List[str]] = None) -> int:
dynamic = Config._app.period_dynamic if Config._app else False
if precision == "datetime":
from datetime import datetime as dt_mod
now = dt_mod.now().isoformat(timespec="seconds")
# Сохраняем aware UTC (#58): следующий запуск вычисляет из этой
# метки aware cutoff для дедупликации.
now = datetime.now(timezone.utc).isoformat(timespec="seconds")
from_str = now
to_str = now
else: