Reject an AI timestamp that has no offset before you store it

Require Z or ±HH:MM on every AI timestamp. Reject naive local times before they hit your database.

Published 2026-12-03 · Translation: VI

In short

  • Write the instant you want before you read the chat reply: full date, time, and Z or a numeric offset.
  • Parse with a real library. Keep the value only when it is timezone-aware.
  • Reject date-only strings and naive 2026-12-03T09:00:00 even when fromisoformat “succeeds.”

ChatGPT and Claude will happily emit a clock reading that looks finished. RFC 3339 timestamps for internet use need a date, a time, and either Z or a numeric offset such as +07:00. A string without that offset is not an instant you can store safely.

Same family of checks as a JSON object you wrote first or a timezone conversion you already computed.

Write the expected instant first

Suppose a shop in Ho Chi Minh City schedules a pickup at 09:00 on 3 December 2026. The sheet you trust is:

2026-12-03T09:00:00+07:00

That is the same instant as 2026-12-03T02:00:00Z. Put that line in your test before you open the chat. The model’s job is to return that shape — not a vague “9am tomorrow.”

Expected: 2026-12-03T09:00:00+07:00. Keep Z or ±HH:MM. Discard a bare local time.

If the product needs a wall-clock recurrence (“every day at 09:00 in Asia/Ho_Chi_Minh”), that is a different type — zone + rule — not a single offset-bearing string.

What parsers accept that you must still discard

Checked on Python 3.15.2 (3 December 2026).

datetime.fromisoformat accepts several ISO-like forms. After replacing a trailing Z with +00:00, these behave as follows:

Input Result Keep?
2026-12-03T09:00:00Z aware, UTC Yes (if your sheet allows Z)
2026-12-03T09:00:00+07:00 aware, +07:00 Yes
2026-12-03T09:00:00 naive No
2026-12-03 date at midnight, naive No

Parser success is not a pass. A naive object has no offset. Calling .astimezone() on it treats the value as the machine’s local zone — which changes between CI, a laptop, and a container.

from datetime import datetime

def accept_instant(s: str) -> datetime:
    raw = s.strip()
    if raw.endswith("Z"):
        raw = raw[:-1] + "+00:00"
    dt = datetime.fromisoformat(raw)
    if dt.tzinfo is None:
        raise ValueError("missing offset")
    return dt.astimezone()  # or convert to UTC explicitly

Good: Z and +07:00 stay. Bad: bare T09:00:00 and date-only both parse as naive.

Product policy may also reject -00:00 (RFC 3339 §4.3: UTC known, local offset unknown). Document that choice; do not silently treat it as Z.

Gate: match your sheet, then store UTC

  1. Ask for one timestamp string.
  2. Run accept_instant.
  3. Compare the UTC instant to the sheet (2026-12-03T02:00:00+00:00 for the example above).
  4. Keep only on an exact match. On failure, ask again with the sheet pasted — do not “fix” the offset yourself.

Write sheet → ask → parse aware → match UTC → keep or discard.

A wrong offset that still parses will land the meeting four hours early. Matching the sheet catches that; “looks like ISO” does not.

Watch-outs

  • Space instead of T (2026-12-03 09:00:00+07:00) often parses in Python; still require an offset.
  • Leap seconds and exotic fractional precision are outside most app contracts — pick a bounded profile and reject the rest.
  • Relative phrases (“next Friday”) belong in a structured extractor, then you compute the instant in code with a known IANA zone.

Share

X Facebook LinkedIn
Educational content only. Rankings reflect stated criteria at the update date—not investment advice or permanent performance guarantees.