Exercise 2 solution from datetime import datetime, timezone, timedelta EPOCH = datetime(1970, 1, 1, tzinfo=timezone.utc) def wrap32(n): n &= 0xFFFFFFFF return n - 2**32 if n >= 2**31 else n last = 2**31 - 1 print("Last signed second:", last, EPOCH + timedelta(seconds=last)) print("Wrapped next value:", wrap32(last + 1), EPOCH + timedelta(seconds=wrap32(last + 1))) now = datetime(2026, 11, 2, 12, 0, tzinfo=timezone.utc) left = (EPOCH + timedelta(seconds=last)) - now print("Time left:", left) print("Whole days:", left.days) print("Last unsigned second:", EPOCH + timedelta(seconds=2**32 - 1)) for n in (last - 1, last, last + 1, last + 2, 2**32 - 1, 2**32): print(n, "->", wrap32(n)) Output (run, and exactly as shown): Last signed second: 2147483647 2038-01-19 03:14:07+00:00 Wrapped next value: -2147483648 1901-12-13 20:45:52+00:00 Time left: 4095 days, 15:14:07 Whole days: 4095 Last unsigned second: 2106-02-07 06:28:15+00:00 2147483646 -> 2147483646 2147483647 -> 2147483647 2147483648 -> -2147483648 2147483649 -> -2147483647 4294967295 -> -1 4294967296 -> 0 Explanation: 2**31 - 1 is the largest signed 32-bit value. One second later the bit pattern reads as -2**31, which is a date in 1901, so software that stores seconds in a signed 32-bit integer jumps backwards. The unsigned limit, 2**32 - 1, is 68 years further on. Python integers never overflow, so wrap32 simulates what a fixed-width integer would do. The fix is to store 64-bit values (or microseconds in 64 bits), not to change the epoch.