Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 023c6f7

Browse files
committed
Fix Issue10403 - datetime documentation clarification based on review in the reitveld by Alexendar belopolsky.
1 parent ad3882a commit 023c6f7

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

Doc/library/datetime.rst

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ miles, or mass. Naive :class:`datetime` objects are easy to understand and to
2525
work with, at the cost of ignoring some aspects of reality.
2626

2727
For applications requiring more, :class:`datetime` and :class:`time` objects
28-
have an optional time zone information attribute, :attr:`tzinfo`, that can contain
29-
an instance of a subclass of the abstract :class:`tzinfo` class. These
28+
have an optional time zone information attribute, :attr:`tzinfo`, that can be
29+
set to an instance of a subclass of the abstract :class:`tzinfo` class. These
3030
:class:`tzinfo` objects capture information about the offset from UTC time, the
3131
time zone name, and whether Daylight Saving Time is in effect. Note that only
3232
one concrete :class:`tzinfo` class, the :class:`timezone` class, is supplied by the
@@ -732,11 +732,13 @@ Other constructors, all class methods:
732732

733733
.. classmethod:: datetime.combine(date, time)
734734

735-
Return a new :class:`datetime` object whose date attributes are equal to the
736-
given :class:`date` object's, and whose time and :attr:`tzinfo` attributes are
737-
equal to the given :class:`time` object's. For any :class:`datetime` object
738-
*d*, ``d == datetime.combine(d.date(), d.timetz())``. If date is a
739-
:class:`datetime` object, its time and :attr:`tzinfo` attributes are ignored.
735+
Return a new :class:`datetime` object whose date components are equal to the
736+
given :class:`date` object's, and whose time components and :attr:`tzinfo`
737+
attributes are equal to the given :class:`time` object's. For any
738+
:class:`datetime` object *d*,
739+
``d == datetime.combine(d.date(), d.timetz())``. If date is a
740+
:class:`datetime` object, its time components and :attr:`tzinfo` attributes
741+
are ignored.
740742

741743

742744
.. classmethod:: datetime.strptime(date_string, format)
@@ -908,13 +910,13 @@ Instance methods:
908910
Return a datetime with the same attributes, except for those attributes given
909911
new values by whichever keyword arguments are specified. Note that
910912
``tzinfo=None`` can be specified to create a naive datetime from an aware
911-
datetime with no conversion of date and time attributes.
913+
datetime with no conversion of date and time data.
912914

913915

914916
.. method:: datetime.astimezone(tz)
915917

916918
Return a :class:`datetime` object with new :attr:`tzinfo` attribute *tz*,
917-
adjusting the date and time attributes so the result is the same UTC time as
919+
adjusting the date and time data so the result is the same UTC time as
918920
*self*, but in *tz*'s local time.
919921

920922
*tz* must be an instance of a :class:`tzinfo` subclass, and its
@@ -923,18 +925,18 @@ Instance methods:
923925
not return ``None``).
924926

925927
If ``self.tzinfo`` is *tz*, ``self.astimezone(tz)`` is equal to *self*: no
926-
adjustment of date or time attributes is performed. Else the result is local
928+
adjustment of date or time data is performed. Else the result is local
927929
time in time zone *tz*, representing the same UTC time as *self*: after
928930
``astz = dt.astimezone(tz)``, ``astz - astz.utcoffset()`` will usually have
929-
the same date and time attributes as ``dt - dt.utcoffset()``. The discussion
931+
the same date and time data as ``dt - dt.utcoffset()``. The discussion
930932
of class :class:`tzinfo` explains the cases at Daylight Saving Time transition
931933
boundaries where this cannot be achieved (an issue only if *tz* models both
932934
standard and daylight time).
933935

934936
If you merely want to attach a time zone object *tz* to a datetime *dt* without
935-
adjustment of date and time attributes, use ``dt.replace(tzinfo=tz)``. If you
937+
adjustment of date and time data, use ``dt.replace(tzinfo=tz)``. If you
936938
merely want to remove the time zone object from an aware datetime *dt* without
937-
conversion of date and time attributes, use ``dt.replace(tzinfo=None)``.
939+
conversion of date and time data, use ``dt.replace(tzinfo=None)``.
938940

939941
Note that the default :meth:`tzinfo.fromutc` method can be overridden in a
940942
:class:`tzinfo` subclass to affect the result returned by :meth:`astimezone`.
@@ -1270,7 +1272,7 @@ Instance methods:
12701272
Return a :class:`time` with the same value, except for those attributes given
12711273
new values by whichever keyword arguments are specified. Note that
12721274
``tzinfo=None`` can be specified to create a naive :class:`time` from an
1273-
aware :class:`time`, without conversion of the time attributes.
1275+
aware :class:`time`, without conversion of the time data.
12741276

12751277

12761278
.. method:: time.isoformat()
@@ -1477,10 +1479,10 @@ There is one more :class:`tzinfo` method that a subclass may wish to override:
14771479

14781480
.. method:: tzinfo.fromutc(dt)
14791481

1480-
This is called from the default :class:`datetime.astimezone()` implementation.
1481-
When called from that, ``dt.tzinfo`` is *self*, and *dt*'s date and time
1482-
attributes are to be viewed as expressing a UTC time. The purpose of
1483-
:meth:`fromutc` is to adjust the date and time attributes, returning an
1482+
This is called from the default :class:`datetime.astimezone()`
1483+
implementation. When called from that, ``dt.tzinfo`` is *self*, and *dt*'s
1484+
date and time data are to be viewed as expressing a UTC time. The purpose
1485+
of :meth:`fromutc` is to adjust the date and time data, returning an
14841486
equivalent datetime in *self*'s local time.
14851487

14861488
Most :class:`tzinfo` subclasses should be able to inherit the default

0 commit comments

Comments
 (0)