Source code for gitlab_overviewer.utils.timestamp

 1"""Timestamp utilities for diagnostic outputs.
 2
 3Implements :any:`/specs/spec_table_rendering_ui` ยง2.2, covering:
 4
 5* ISO8601 timestamp formatting
 6* Timezone handling (UTC)
 7
 8This module provides functions for generating consistent, timezone-aware
 9timestamps in ISO8601 format for use in diagnostic output filenames.
10"""
11
12from datetime import datetime, timezone
13
14
[docs] 15def now_iso() -> str: 16 """Generate an ISO8601 UTC timestamp suitable for filenames. 17 18 Returns: 19 str: Current UTC time in format 'YYYY-MM-DDTHH-MM-SSZ' 20 Example: '2025-03-18T14-55-30Z' 21 """ 22 now = datetime.now(timezone.utc) 23 # Use - instead of : in time portion for filename compatibility 24 return now.strftime("%Y-%m-%dT%H-%M-%SZ")