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

1# Copyright (c) 2024 Prosemark Contributors 

2# This software is licensed under the MIT License 

3 

4"""System clock implementation for timestamp generation.""" 

5 

6from datetime import UTC, datetime 

7 

8from prosemark.ports.clock import Clock 

9 

10 

11class ClockSystem(Clock): 

12 """Production clock implementation using system time. 

13 

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 

20 

21 The generated timestamps are always in UTC timezone with 'Z' suffix 

22 for consistency and to avoid timezone-related issues. 

23 """ 

24 

25 def now_iso(self) -> str: 

26 """Generate current timestamp in ISO8601 UTC format. 

27 

28 Returns: 

29 Current system time as ISO8601 formatted string in UTC with 'Z' suffix 

30 Format: "2025-09-20T15:30:45Z" 

31 

32 """ 

33 return datetime.now(UTC).isoformat().replace('+00:00', 'Z')