1111
1212 The :mod: `datetime ` module supplies classes for manipulating dates and times in
1313both simple and complex ways. While date and time arithmetic is supported, the
14- focus of the implementation is on efficient member extraction for output
14+ focus of the implementation is on efficient attribute extraction for output
1515formatting and manipulation. For related
1616functionality, see also the :mod: `time ` and :mod: `calendar ` modules.
1717
@@ -25,7 +25,7 @@ miles, or mass. Naive :class:`datetime` objects are easy to understand and to
2525work with, at the cost of ignoring some aspects of reality.
2626
2727For applications requiring more, :class: `datetime ` and :class: `time ` objects
28- have an optional time zone information member , :attr: `tzinfo `, that can contain
28+ have an optional time zone information attribute , :attr: `tzinfo `, that can contain
2929an instance of a subclass of the abstract :class: `tzinfo ` class. These
3030:class: `tzinfo ` objects capture information about the offset from UTC time, the
3131time zone name, and whether Daylight Saving Time is in effect. Note that only
@@ -499,9 +499,9 @@ Instance methods:
499499
500500.. method :: date.replace(year, month, day)
501501
502- Return a date with the same value, except for those members given new values by
503- whichever keyword arguments are specified. For example, if ``d == date(2002,
504- 12, 31) ``, then ``d.replace(day=26) == date(2002, 12, 26) ``.
502+ Return a date with the same value, except for those parameters given new
503+ values by whichever keyword arguments are specified. For example, if ``d ==
504+ date(2002, 12, 31) ``, then ``d.replace(day=26) == date(2002, 12, 26) ``.
505505
506506
507507.. method :: date.timetuple()
@@ -748,11 +748,11 @@ Other constructors, all class methods:
748748
749749.. classmethod :: datetime.combine(date, time)
750750
751- Return a new :class: `datetime ` object whose date members are equal to the given
752- :class: `date ` object's, and whose time and :attr: `tzinfo ` members are equal to
753- the given :class: `time ` object's. For any :class: `datetime ` object * d *, `` d ==
754- datetime.combine(d.date(), d.timetz()) ``. If date is a :class: ` datetime `
755- object, its time and :attr: `tzinfo ` members are ignored.
751+ Return a new :class: `datetime ` object whose date attributes are equal to the
752+ given :class: `date ` object's, and whose time and :attr: `tzinfo ` attributes are
753+ equal to the given :class: `time ` object's. For any :class: `datetime ` object
754+ * d *, `` d == datetime.combine(d.date(), d.timetz()) ``. If date is a
755+ :class: ` datetime ` object, its time and :attr: `tzinfo ` attributes are ignored.
756756
757757
758758.. classmethod :: datetime.strptime(date_string, format)
@@ -846,43 +846,44 @@ Supported operations:
846846(1)
847847 datetime2 is a duration of timedelta removed from datetime1, moving forward in
848848 time if ``timedelta.days `` > 0, or backward if ``timedelta.days `` < 0. The
849- result has the same :attr: `tzinfo ` member as the input datetime, and datetime2 -
850- datetime1 == timedelta after. :exc: `OverflowError ` is raised if datetime2.year
851- would be smaller than :const: `MINYEAR ` or larger than :const: `MAXYEAR `. Note
852- that no time zone adjustments are done even if the input is an aware object.
849+ result has the same :attr: `tzinfo ` attribute as the input datetime, and
850+ datetime2 - datetime1 == timedelta after. :exc: `OverflowError ` is raised if
851+ datetime2.year would be smaller than :const: `MINYEAR ` or larger than
852+ :const: `MAXYEAR `. Note that no time zone adjustments are done even if the
853+ input is an aware object.
853854
854855(2)
855856 Computes the datetime2 such that datetime2 + timedelta == datetime1. As for
856- addition, the result has the same :attr: `tzinfo ` member as the input datetime,
857- and no time zone adjustments are done even if the input is aware. This isn't
858- quite equivalent to datetime1 + (-timedelta), because -timedelta in isolation
859- can overflow in cases where datetime1 - timedelta does not.
857+ addition, the result has the same :attr: `tzinfo ` attribute as the input
858+ datetime, and no time zone adjustments are done even if the input is aware.
859+ This isn't quite equivalent to datetime1 + (-timedelta), because -timedelta
860+ in isolation can overflow in cases where datetime1 - timedelta does not.
860861
861862(3)
862863 Subtraction of a :class: `datetime ` from a :class: `datetime ` is defined only if
863864 both operands are naive, or if both are aware. If one is aware and the other is
864865 naive, :exc: `TypeError ` is raised.
865866
866- If both are naive, or both are aware and have the same :attr: `tzinfo ` member ,
867- the :attr: `tzinfo ` members are ignored, and the result is a :class: `timedelta `
867+ If both are naive, or both are aware and have the same :attr: `tzinfo ` attribute ,
868+ the :attr: `tzinfo ` attributes are ignored, and the result is a :class: `timedelta `
868869 object *t * such that ``datetime2 + t == datetime1 ``. No time zone adjustments
869870 are done in this case.
870871
871- If both are aware and have different :attr: `tzinfo ` members , ``a-b `` acts as if
872- *a * and *b * were first converted to naive UTC datetimes first. The result is
873- ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None) -
874- b.utcoffset()) `` except that the implementation never overflows.
872+ If both are aware and have different :attr: `tzinfo ` attributes , ``a-b `` acts
873+ as if *a * and *b * were first converted to naive UTC datetimes first. The
874+ result is ``(a.replace(tzinfo=None) - a.utcoffset()) - (b.replace(tzinfo=None)
875+ - b.utcoffset()) `` except that the implementation never overflows.
875876
876877(4)
877878 *datetime1 * is considered less than *datetime2 * when *datetime1 * precedes
878879 *datetime2 * in time.
879880
880881 If one comparand is naive and the other is aware, :exc: `TypeError ` is raised.
881- If both comparands are aware, and have the same :attr: `tzinfo ` member , the
882- common :attr: `tzinfo ` member is ignored and the base datetimes are compared. If
883- both comparands are aware and have different :attr: `tzinfo ` members, the
884- comparands are first adjusted by subtracting their UTC offsets (obtained from
885- ``self.utcoffset() ``).
882+ If both comparands are aware, and have the same :attr: `tzinfo ` attribute , the
883+ common :attr: `tzinfo ` attribute is ignored and the base datetimes are
884+ compared. If both comparands are aware and have different :attr: `tzinfo `
885+ attributes, the comparands are first adjusted by subtracting their UTC
886+ offsets (obtained from ``self.utcoffset() ``).
886887
887888 .. note ::
888889
@@ -915,41 +916,41 @@ Instance methods:
915916.. method :: datetime.timetz()
916917
917918 Return :class: `time ` object with same hour, minute, second, microsecond, and
918- tzinfo members . See also method :meth: `time `.
919+ tzinfo attributes . See also method :meth: `time `.
919920
920921
921922.. method :: datetime.replace([year[, month[, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]]]]])
922923
923- Return a datetime with the same members , except for those members given new
924- values by whichever keyword arguments are specified. Note that `` tzinfo=None ``
925- can be specified to create a naive datetime from an aware datetime with no
926- conversion of date and time members .
924+ Return a datetime with the same attributes , except for those attributes given
925+ new values by whichever keyword arguments are specified. Note that
926+ `` tzinfo=None `` can be specified to create a naive datetime from an aware
927+ datetime with no conversion of date and time attributes .
927928
928929
929930.. method :: datetime.astimezone(tz)
930931
931- Return a :class: `datetime ` object with new :attr: `tzinfo ` member *tz *, adjusting
932- the date and time members so the result is the same UTC time as * self *, but in
933- *tz *'s local time.
932+ Return a :class: `datetime ` object with new :attr: `tzinfo ` attribute *tz *,
933+ adjusting the date and time attributes so the result is the same UTC time as
934+ *self *, but in * tz *'s local time.
934935
935936 *tz * must be an instance of a :class: `tzinfo ` subclass, and its
936937 :meth: `utcoffset ` and :meth: `dst ` methods must not return ``None ``. *self * must
937938 be aware (``self.tzinfo `` must not be ``None ``, and ``self.utcoffset() `` must
938939 not return ``None ``).
939940
940941 If ``self.tzinfo `` is *tz *, ``self.astimezone(tz) `` is equal to *self *: no
941- adjustment of date or time members is performed. Else the result is local time
942- in time zone *tz *, representing the same UTC time as *self *: after `` astz =
943- dt.astimezone(tz) ``, ``astz - astz.utcoffset() `` will usually have the same date
944- and time members as ``dt - dt.utcoffset() ``. The discussion of class
945- :class: `tzinfo ` explains the cases at Daylight Saving Time transition boundaries
946- where this cannot be achieved (an issue only if *tz * models both standard and
947- daylight time).
942+ adjustment of date or time attributes is performed. Else the result is local
943+ time in time zone *tz *, representing the same UTC time as *self *: after
944+ `` astz = dt.astimezone(tz) ``, ``astz - astz.utcoffset() `` will usually have
945+ the same date and time attributes as ``dt - dt.utcoffset() ``. The discussion
946+ of class :class: `tzinfo ` explains the cases at Daylight Saving Time transition
947+ boundaries where this cannot be achieved (an issue only if *tz * models both
948+ standard and daylight time).
948949
949950 If you merely want to attach a time zone object *tz * to a datetime *dt * without
950- adjustment of date and time members , use ``dt.replace(tzinfo=tz) ``. If you
951+ adjustment of date and time attributes , use ``dt.replace(tzinfo=tz) ``. If you
951952 merely want to remove the time zone object from an aware datetime *dt * without
952- conversion of date and time members , use ``dt.replace(tzinfo=None) ``.
953+ conversion of date and time attributes , use ``dt.replace(tzinfo=None) ``.
953954
954955 Note that the default :meth: `tzinfo.fromutc ` method can be overridden in a
955956 :class: `tzinfo ` subclass to affect the result returned by :meth: `astimezone `.
@@ -1260,14 +1261,14 @@ Supported operations:
12601261* comparison of :class: `time ` to :class: `time `, where *a * is considered less
12611262 than *b * when *a * precedes *b * in time. If one comparand is naive and the other
12621263 is aware, :exc: `TypeError ` is raised. If both comparands are aware, and have
1263- the same :attr: `tzinfo ` member , the common :attr: `tzinfo ` member is ignored and
1264- the base times are compared. If both comparands are aware and have different
1265- :attr: `tzinfo ` members , the comparands are first adjusted by subtracting their
1266- UTC offsets (obtained from ``self.utcoffset() ``). In order to stop mixed-type
1267- comparisons from falling back to the default comparison by object address, when
1268- a :class: `time ` object is compared to an object of a different type,
1269- :exc: `TypeError ` is raised unless the comparison is ``== `` or `` != ``. The
1270- latter cases return :const: `False ` or :const: `True `, respectively.
1264+ the same :attr: `tzinfo ` attribute , the common :attr: `tzinfo ` attribute is
1265+ ignored and the base times are compared. If both comparands are aware and
1266+ have different :attr: `tzinfo ` attributes , the comparands are first adjusted by
1267+ subtracting their UTC offsets (obtained from ``self.utcoffset() ``). In order
1268+ to stop mixed-type comparisons from falling back to the default comparison by
1269+ object address, when a :class: `time ` object is compared to an object of a
1270+ different type, :exc: `TypeError ` is raised unless the comparison is ``== `` or
1271+ `` != ``. The latter cases return :const: `False ` or :const: `True `, respectively.
12711272
12721273* hash, use as dict key
12731274
@@ -1282,10 +1283,10 @@ Instance methods:
12821283
12831284.. method :: time.replace([hour[, minute[, second[, microsecond[, tzinfo]]]]])
12841285
1285- Return a :class: `time ` with the same value, except for those members given new
1286- values by whichever keyword arguments are specified. Note that `` tzinfo=None ``
1287- can be specified to create a naive :class: `time ` from an aware :class: ` time `,
1288- without conversion of the time members .
1286+ Return a :class: `time ` with the same value, except for those attributes given
1287+ new values by whichever keyword arguments are specified. Note that
1288+ `` tzinfo=None `` can be specified to create a naive :class: `time ` from an
1289+ aware :class: ` time `, without conversion of the time attributes .
12891290
12901291
12911292.. method :: time.isoformat()
@@ -1370,7 +1371,7 @@ EDT.
13701371
13711372An instance of (a concrete subclass of) :class: `tzinfo ` can be passed to the
13721373constructors for :class: `datetime ` and :class: `time ` objects. The latter objects
1373- view their members as being in local time, and the :class: `tzinfo ` object
1374+ view their attributes as being in local time, and the :class: `tzinfo ` object
13741375supports methods revealing offset of local time from UTC, the name of the time
13751376zone, and DST offset, all relative to a date or time object passed to them.
13761377
@@ -1415,9 +1416,9 @@ methods. Exactly which methods are needed depends on the uses made of aware
14151416 already been added to the UTC offset returned by :meth: `utcoffset `, so there's
14161417 no need to consult :meth: `dst ` unless you're interested in obtaining DST info
14171418 separately. For example, :meth: `datetime.timetuple ` calls its :attr: `tzinfo `
1418- member 's :meth: `dst ` method to determine how the :attr: `tm_isdst ` flag should be
1419- set, and :meth: `tzinfo.fromutc ` calls :meth: `dst ` to account for DST changes
1420- when crossing time zones.
1419+ attribute 's :meth: `dst ` method to determine how the :attr: `tm_isdst ` flag
1420+ should be set, and :meth: `tzinfo.fromutc ` calls :meth: `dst ` to account for
1421+ DST changes when crossing time zones.
14211422
14221423 An instance *tz * of a :class: `tzinfo ` subclass that models both standard and
14231424 daylight times must be consistent in this sense:
@@ -1493,10 +1494,10 @@ There is one more :class:`tzinfo` method that a subclass may wish to override:
14931494.. method :: tzinfo.fromutc(dt)
14941495
14951496 This is called from the default :class: `datetime.astimezone() ` implementation.
1496- When called from that, ``dt.tzinfo `` is *self *, and *dt *'s date and time members
1497- are to be viewed as expressing a UTC time. The purpose of :meth: ` fromutc ` is to
1498- adjust the date and time members , returning an equivalent datetime in * self *'s
1499- local time.
1497+ When called from that, ``dt.tzinfo `` is *self *, and *dt *'s date and time
1498+ attributes are to be viewed as expressing a UTC time. The purpose of
1499+ :meth: ` fromutc ` is to adjust the date and time attributes , returning an
1500+ equivalent datetime in * self *'s local time.
15001501
15011502 Most :class: `tzinfo ` subclasses should be able to inherit the default
15021503 :meth: `fromutc ` implementation without problems. It's strong enough to handle
0 commit comments