8000 bpo-9004: Recommend against using utctimetuple in the docs. by abalkin · Pull Request #10870 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-9004: Recommend against using utctimetuple in the docs. #10870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
7 changes: 6 additions & 1 deletion Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ Other constructors, all class methods:
If *tz* is not ``None``, it must be an instance of a :class:`tzinfo` subclass, and the
current date and time are converted to *tz*’s time zone. In this case the
result is equivalent to ``tz.fromutc(datetime.utcnow().replace(tzinfo=tz))``.
It is recommended to create aware datetime object for current UTC time by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am not a native english speaker but shouldn't this "It is recommended to create aware datetime object " be "It is recommended to create an aware datetime object for current" or "be "It is recommended to create aware datetime objects for current"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am not a native english speaker neither but I'd propose:

The recommended way to create aware datetime object for the current time in UTC is ...

calling ``datetime.now(timezone.utc)``.
See also :meth:`today`, :meth:`utcnow`.


Expand Down Expand Up @@ -1134,7 +1136,10 @@ Instance methods:
of the result is set according to the :meth:`dst` method: :attr:`.tzinfo` is
``None`` or :meth:`dst` returns ``None``, :attr:`tm_isdst` is set to ``-1``;
else if :meth:`dst` returns a non-zero value, :attr:`tm_isdst` is set to ``1``;
else :attr:`tm_isdst` is set to ``0``.
else :attr:`tm_isdst` is set to ``0``. To obtain UTC timetuple, it is
recommended to use ``datetime.astimezone(timezone.utc).timetuple()`` because
unlike :meth:`utctimetuple` method, :meth:`timetuple` method does not force
:attr:`tm_isdst` to ``0``.


.. method:: datetime.utctimetuple()
Expand Down
0