Files
DumiFlex 3d24b4bc6a fix(engine): bump now_iso() to microsecond precision
CI failure on python 3.11/3.12: test_update_bumps_version_and_updated_at
asserts updated_at > created_at, but ms-precision timestamps collide when
SQLite create + update fire inside the same millisecond on fast runners.

Microsecond precision (6 fractional digits) keeps ISO-8601 valid, TS
Date.parse handles it natively, and no consumer regex-binds to the
3-digit form. Fixes the repository ordering invariant.
2026-04-28 09:07:51 +03:00

20 lines
773 B
Python

"""Shared utility helpers used across the engine + wp_api packages."""
from __future__ import annotations
import datetime as _dt
def now_iso() -> str:
"""UTC ISO timestamp with microsecond precision and ``Z`` suffix.
Used for `created_at`, `updated_at`, `library_snapshot_at`,
migration `applied_at`, and import-export `exported_at`. Single source
of truth so the format never drifts between callers.
Microsecond precision (vs. millisecond) prevents collisions when
two ops fire inside the same millisecond on fast CI runners — the
`updated_at > created_at` invariant in `ModuleRepository.update`
must hold for any sequential create+update pair.
"""
return _dt.datetime.now(_dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")