FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-9004: Recommend against using utctimetuple in the docs. by abalkin · Pull Request #10870 · python/cpython · GitHub

/ cpython Public
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 6 additions & 1 deletion Doc/library/datetime.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Back | FazBrowse Home | New Git URL