# How to verify that a Python UTC conversion preserves the instant

A simulated fill recorded at 14:30 Hong Kong time belongs at 06:30 UTC when you sort it alongside UTC order logs. If you keep 14:30 and assign a UTC offset, the timestamp moves eight hours later. During reconciliation, that can put the fill on the wrong side of an order event.

## Run the check in Python 3.12

The AlgoRover Live paper ledger records a simulated Binance ETHUSDT perpetual short entry on November 15, 2026. The Python 3.12 check used `2026-11-15T14:30:00+08:00`. The ledger records time to the minute, so `:00` fills out the timestamp without adding precision. [EP-0080 paper ledger](https://chatgpt.com/s/cx_6afb219998808191a8f27dadb5360672)

```python
from datetime import datetime, timezone

local = datetime.fromisoformat("2026-11-15T14:30:00+08:00")
utc = local.astimezone(timezone.utc)

print(utc.isoformat())
print(f"instant_equal={local == utc}")
assert local == utc
```

The recorded run printed the following output.

```text
2026-11-15T06:30:00+00:00
instant_equal=True
```

The first line matches `observed.utc` in the run record, including the `+00:00` offset. The assertion checks that the timestamps represent the same instant. Python accounts for the offsets when comparing these fixed-offset datetimes, so `14:30+08:00` and `06:30+00:00` compare equal.

## What `replace(tzinfo=timezone.utc)` changes

`astimezone` adjusts the clock reading to preserve the instant. `replace` keeps the clock fields and assigns a new offset. Applied to this input, `replace` would produce `2026-11-15T14:30:00+00:00`, eight hours after the original instant. The recorded run covered `astimezone` and its equality check.

If a timestamp arrives without an offset, check which time zone the source uses before converting it. `astimezone` treats a naive datetime as system-local time, so converting it directly can give different results on machines set to different time zones.
