
A support export combines entries written by devices in different time zones. Comparing the displayed hour can reverse the real order of events across a daylight boundary. Conversion places each event on one timeline and can change the calendar day. The offset in the string supplies the information required for that conversion.
Reproduce the input boundary
The script runs datetime.fromisoformat against three independent inputs. Each call starts from the value shown, so changing one example leaves the other expectations available for comparison. The table records real return values from the example. Quotation marks around text in the table make its boundaries visible.
from datetime import datetime, timezone
def evaluate(value):
return datetime.fromisoformat(value).astimezone(timezone.utc).isoformat()
for sample in ['2026-12-01T09:00:00+05:30', '2026-12-01T04:00:00+00:00', '2026-11-30T23:45:00-05:00']:
print(evaluate(sample))Read the output as a contract
| Input to evaluate | Observed result |
|---|---|
| '2026-12-01T09:00:00+05:30' | '2026-12-01T03:30:00+00:00' |
| '2026-12-01T04:00:00+00:00' | '2026-12-01T04:00:00+00:00' |
| '2026-11-30T23:45:00-05:00' | '2026-12-01T04:45:00+00:00' |
For '2026-12-01T09:00:00+05:30', the observed output is '2026-12-01T03:30:00+00:00'. With '2026-12-01T04:00:00+00:00', it becomes '2026-12-01T04:00:00+00:00'. These are useful regression fixtures because an integration test can send both through the same entry point. A test of only the first case can stay green after a change that affects the other.
The result for '2026-11-30T23:45:00-05:00' is text, '2026-12-01T04:45:00+00:00'. Compare the resulting characters directly in a test. If two outputs look identical on screen, printing a quoted representation can expose a trailing space, a line boundary or an escaped character.
Connect the example to a regression test
Reject naïve timestamps when the source timezone is unknown. Letting the host machine choose silently ties the answer to where the code runs.
A practical test can begin with assert evaluate('2026-12-01T09:00:00+05:30') == '2026-12-01T03:30:00+00:00'. Add the other rows as separate expectations so one failure identifies the input that changed. For a service fed by stored data, repeat the check on one anonymized record from an earlier version of its file or message format.
A second check against a changed input
Sort normalized instants, then format them for each reader. If the audit log must reproduce what the operator originally saw, retain the supplied timestamp text or original offset alongside the normalized value.
The same Python function was also run with '' / '2026-12-01T09:00:00+05:30 ' / '03:50+00:00:90T10-21-6202'. These additional inputs change the boundary without changing the implementation. An exception name in the table records where the operation rejects an input; a returned empty or zero value records a successful call. Choose deliberately which of those outcomes the surrounding feature should expose.
| Additional fixture | Result or exception |
|---|---|
| '' | raises ValueError |
| '2026-12-01T09:00:00+05:30 ' | raises ValueError |
| '03:50+00:00:90T10-21-6202' | raises ValueError |
Python’s datetime reference · Python standard library
Sources and further reading
Cover photograph: Mechanical keyboard caps at Comic Fiesta 2024 by PeaceSeekers. CC BY-SA 4.0. Cropped and typeset for this cover. The photograph illustrates the topic. This image adaptation uses the same share-alike license.
