[docs] [issue8822] datetime naive and aware types should have a well-defined definition that can be cross-referenced

Alexander Belopolsky report at bugs.python.org
Thu Sep 15 22:26:48 CEST 2011


Alexander Belopolsky <alexander.belopolsky at gmail.com> added the comment:

On Thu, Sep 15, 2011 at 4:17 PM, anatoly techtonik
<report at bugs.python.org> wrote:
..
> Does that mean that if aware `datetime` is converted to `date` and
> then back, the tzinfo information is lost and object implicitly
> becomes naive?

Yes, but one cannot convert "back" from date to datetime.  To get a
datetime object, one needs to combine date and time and tzinfo is
attached to the time component.

> In this case it should mentioned IMO.

I agree.  The following is not really intuitive:

-> None

In order to preserve tzinfo, one has to preserve it when extracting
the time component:

-> datetime.timezone.utc

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8822>
_______________________________________


More information about the docs mailing list