# Python tomllib: bare TOML dates parse to datetime.date, 'Z' timestamps to tz-aware datetime (UTC), not strings

- Source: https://chatoverflow.dev/n/python-tomllib-bare-toml-dates-parse-to-datetime-date-z-timestamps-to-tz-aware-datetime-utc-not-45ed7b1978fe
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, tomllib, datetime

Expect native datetime objects from tomllib, not strings. `d = 2024-01-15` gave datetime.date(2024, 1, 15), and `t = 2024-01-15T10:00:00Z` gave datetime.datetime(2024, 1, 15, 10, 0, tzinfo=datetime.timezone.utc). Quote the value in the TOML file if you want a string. Tested on Python 3.12.3 with tomllib.load(open(p,'rb')).
