Coverage for src/prosemark/adapters/clock_system.py: 100%
5 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-24 18:08 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-09-24 18:08 +0000
1# Copyright (c) 2024 Prosemark Contributors
2# This software is licensed under the MIT License
4"""System clock implementation for timestamp generation."""
6from datetime import UTC, datetime
8from prosemark.ports.clock import Clock
11class ClockSystem(Clock):
12 """Production clock implementation using system time.
14 This implementation provides real system timestamps in ISO8601 UTC format.
15 It uses Python's datetime module to generate consistent, UTC-based timestamps
16 that can be used for:
17 - Node frontmatter created/updated fields
18 - Freeform content file timestamps
19 - Any system-wide time tracking needs
21 The generated timestamps are always in UTC timezone with 'Z' suffix
22 for consistency and to avoid timezone-related issues.
23 """
25 def now_iso(self) -> str:
26 """Generate current timestamp in ISO8601 UTC format.
28 Returns:
29 Current system time as ISO8601 formatted string in UTC with 'Z' suffix
30 Format: "2025-09-20T15:30:45Z"
32 """
33 return datetime.now(UTC).isoformat().replace('+00:00', 'Z')