﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35683	django.utils.timezone.make_naive can underflow for timezones close to datetime.min	Liam DeVoe		"I'm a contributor over at [https://github.com/HypothesisWorks/hypothesis Hypothesis]. [https://github.com/HypothesisWorks/hypothesis/pull/4086#issuecomment-2290742590 We found] that saving (or retrieving?) models with aware DateTimeField values close to datetime.min can error if:
* timezone support is enabled (USE_TZ=True)
* you are using the sqlite database (presumably also any other db backend without tz aware support, if they exist?)

Explicitly:

{{{
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
from django.utils.timezone import make_naive

dt = datetime.min.replace(tzinfo=ZoneInfo(key='Africa/Addis_Ababa'))
make_naive(dt, timezone.utc) # OverflowError
}}}

where make_naive is called from [https://github.com/django/django/blob/a57596e443ecb67140e1a9fc0f0e87446b2d0174/django/db/backends/sqlite3/operations.py#L269 here]. I would guess the overflow case for datetime.max is symmetric and similar as well.

I hope you'll forgive the lack of a django reproducer - I live in testing land and don't have a local django environment handy :). Hopefully the cause is clear and reproducible with vanilla django models."	Bug	new	Uncategorized	5.1	Normal				Unreviewed	0	0	0	0	0	0
