"""Windows/Rust timestamps must also parse on the Python 3.10 operator host.""" from datetime import datetime, timezone from pathlib import Path import sys import unittest sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'tools')) from windows_update_scope import stamp class TimestampFormats(unittest.TestCase): def test_platform_fractional_precision(self): for fraction in ('', '.4', '.490', '.490042', '.4900421', '.490042100'): with self.subTest(fraction=fraction): value=stamp('2026-11-17T16:32:32'+fraction+'Z') self.assertEqual(value.second,32) self.assertEqual(value.microsecond, int((fraction[1:]+'000000')[:6])) self.assertEqual(value.utcoffset().total_seconds(),0) def test_offset_and_comparison(self): self.assertEqual(stamp('2026-11-17T17:32:32.490042100+01:00'), datetime(2026,11,17,16,32,32,490042,tzinfo=timezone.utc)) def test_malformed_and_unqualified_are_rejected(self): for value in ('2026-11-17T16:32:32','2026-11-17T16:32:32.4900421000Z','invalid'): with self.subTest(value=value), self.assertRaises(ValueError):stamp(value) if __name__=='__main__':unittest.main()