make_aware(value, timezone=None, is_dst=None)
[source]
Returns an aware datetime
that represents the same point in time as value
in timezone
, value
being a naive datetime
. If timezone
is set to None
, it defaults to the current time zone.
When pytz is installed, the exception pytz.AmbiguousTimeError
will be raised if you try to make value
aware during a DST transition where the same time occurs twice (when reverting from DST). Setting is_dst
to True
or False
will avoid the exception by choosing if the time is pre-transition or post-transition respectively.
When pytz is installed, the exception pytz.NonExistentTimeError
will be raised if you try to make value
aware during a DST transition such that the time never occurred (when entering into DST). Setting is_dst
to True
or False
will avoid the exception by moving the hour backwards or forwards by 1 respectively. For example, is_dst=True
would change a non-existent time of 2:30 to 1:30 and is_dst=False
would change the time to 3:30.
is_dst
has no effect when pytz
is not installed.
The is_dst
argument was added.
Please login to continue.