If I do:
>>> datetime.max.astimezone(pytz.UTC)
datetime.datetime(9999, 12, 31, 23, 59, 59, 999999, tzinfo=<UTC>)
>>> datetime.min.astimezone(pytz.UTC)
ValueError: year 0 is out of range
However:
datetime.min.replace(tzinfo=pytz.UTC)
datetime.datetime(1, 1, 1, 0, 0, tzinfo=<UTC>)
From this and this answers, it seems a conversion issue.
Is this a bug or an intended behaviour, and why?
astimezone? if you just need datetime.min / .max as a placeholder as aware datetime,replacedoes the trick. Python's naive datetime resembling something like local time brings some complications with it, this is one of them IIUC. One could argue about if this was a good design decision or not. But a bug existing still in 3.11 suggests there's no easy solution on the way.