From d108a3c1935c7b7b7c9620bcbb0efc6d253b241d Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Sat, 5 Mar 2022 08:51:37 -0800 Subject: [PATCH 1/5] Removed east/west references from datetime --- Doc/library/datetime.rst | 4 ++-- Lib/datetime.py | 18 ++++++++---------- Modules/_datetimemodule.c | 10 +++++----- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index f447b7bc9491e4d..974b47518449a39 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -1954,8 +1954,8 @@ Examples of working with a :class:`.time` object:: .. method:: tzinfo.utcoffset(dt) - Return offset of local time from UTC, as a :class:`timedelta` object that is - positive east of UTC. If local time is west of UTC, this should be negative. + Returns the dfference between local time and UTC as a :class:`timedelta` object. + One must add this offset to UTC to arrive at local time. This represents the *total* offset from UTC; for example, if a :class:`tzinfo` object represents both time zone and DST adjustments, diff --git a/Lib/datetime.py b/Lib/datetime.py index 6bf37ccfab7ac86..4dbdce5142ee18e 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1123,11 +1123,11 @@ def tzname(self, dt): raise NotImplementedError("tzinfo subclass must override tzname()") def utcoffset(self, dt): - "datetime -> timedelta, positive for east of UTC, negative for west of UTC" + "Returns the difference between local time and UTC as a timedelta object." raise NotImplementedError("tzinfo subclass must override utcoffset()") def dst(self, dt): - """datetime -> DST offset as timedelta, positive for east of UTC. + """Returns the DST offset as a timedelta object. Return 0 if DST not in effect. utcoffset() must include the DST offset. @@ -1466,8 +1466,7 @@ def __format__(self, fmt): # Timezone functions def utcoffset(self): - """Return the timezone offset as timedelta, positive east of UTC - (negative west of UTC).""" + """Returns the difference between local time and UTC as a timedelta object.""" if self._tzinfo is None: return None offset = self._tzinfo.utcoffset(None) @@ -1488,8 +1487,8 @@ def tzname(self): return name def dst(self): - """Return 0 if DST is not in effect, or the DST offset (as timedelta - positive eastward) if DST is in effect. + """Returns the DST offset as a timedelta object, or timedelta(0) if + DST is not in effect. This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there's no @@ -1951,8 +1950,7 @@ def strptime(cls, date_string, format): return _strptime._strptime_datetime(cls, date_string, format) def utcoffset(self): - """Return the timezone offset as timedelta positive east of UTC (negative west of - UTC).""" + """Returns the difference between local time and UTC as a timedelta object.""" if self._tzinfo is None: return None offset = self._tzinfo.utcoffset(self) @@ -1973,8 +1971,8 @@ def tzname(self): return name def dst(self): - """Return 0 if DST is not in effect, or the DST offset (as timedelta - positive eastward) if DST is in effect. + """Returns the DST offset as a timedelta object, or timedelta(0) if + DST is not in effect. This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there's no diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index ae97190bccbde09..4ba12011d8c10a7 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -1199,7 +1199,7 @@ call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg) * doesn't return None or timedelta, TypeError is raised and this returns -1. * If utcoffset() returns an out of range timedelta, * ValueError is raised and this returns -1. Else *none is - * set to 0 and the offset is returned (as timedelta, positive east of UTC). + * set to 0 and the offset from UTC is returned as int # of minutes. */ static PyObject * call_utcoffset(PyObject *tzinfo, PyObject *tzinfoarg) @@ -1213,7 +1213,7 @@ call_utcoffset(PyObject *tzinfo, PyObject *tzinfoarg) * doesn't return None or timedelta, TypeError is raised and this * returns -1. If dst() returns an invalid timedelta for a UTC offset, * ValueError is raised and this returns -1. Else *none is set to 0 and - * the offset is returned (as timedelta, positive east of UTC). + * the offset from local time is returned as an int # of minutes. */ static PyObject * call_dst(PyObject *tzinfo, PyObject *tzinfoarg) @@ -3790,11 +3790,11 @@ static PyMethodDef tzinfo_methods[] = { PyDoc_STR("datetime -> string name of time zone.")}, {"utcoffset", (PyCFunction)tzinfo_utcoffset, METH_O, - PyDoc_STR("datetime -> timedelta showing offset from UTC, negative " - "values indicating West of UTC")}, + PyDoc_STR("Returns the difference between local time and UTC as a timedelta " + "object.")}, {"dst", (PyCFunction)tzinfo_dst, METH_O, - PyDoc_STR("datetime -> DST offset as timedelta positive east of UTC.")}, + PyDoc_STR("Returns the DST offset as a timedelta object.")}, {"fromutc", (PyCFunction)tzinfo_fromutc, METH_O, PyDoc_STR("datetime in UTC -> datetime in local time.")}, From a7abd646ba7c96e696df224589fe477524b4d246 Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Sat, 5 Mar 2022 09:08:11 -0800 Subject: [PATCH 2/5] Removed random spacing --- Lib/datetime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/datetime.py b/Lib/datetime.py index 4dbdce5142ee18e..90670de4c60002b 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1487,8 +1487,8 @@ def tzname(self): return name def dst(self): - """Returns the DST offset as a timedelta object, or timedelta(0) if - DST is not in effect. + """Returns the DST offset as a timedelta object, or timedelta(0) if + DST is not in effect. This is purely informational; the DST offset has already been added to the UTC offset returned by utcoffset() if applicable, so there's no From 7956f1ebaacd828d380c519e1d8f041ff8723365 Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Sun, 3 Apr 2022 09:19:21 -0700 Subject: [PATCH 3/5] Returns -> Return, # -> number --- Doc/library/datetime.rst | 2 +- Lib/datetime.py | 10 +++++----- Modules/_datetimemodule.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 974b47518449a39..02c68382a6eede6 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -1954,7 +1954,7 @@ Examples of working with a :class:`.time` object:: .. method:: tzinfo.utcoffset(dt) - Returns the dfference between local time and UTC as a :class:`timedelta` object. + Return the difference between local time and UTC as a :class:`timedelta` object. One must add this offset to UTC to arrive at local time. This represents the *total* offset from UTC; for example, if a diff --git a/Lib/datetime.py b/Lib/datetime.py index 90670de4c60002b..847080b526a75ef 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1127,7 +1127,7 @@ def utcoffset(self, dt): raise NotImplementedError("tzinfo subclass must override utcoffset()") def dst(self, dt): - """Returns the DST offset as a timedelta object. + """Return the DST offset as a timedelta object. Return 0 if DST not in effect. utcoffset() must include the DST offset. @@ -1466,7 +1466,7 @@ def __format__(self, fmt): # Timezone functions def utcoffset(self): - """Returns the difference between local time and UTC as a timedelta object.""" + """Return the difference between local time and UTC as a timedelta object.""" if self._tzinfo is None: return None offset = self._tzinfo.utcoffset(None) @@ -1487,7 +1487,7 @@ def tzname(self): return name def dst(self): - """Returns the DST offset as a timedelta object, or timedelta(0) if + """Return the DST offset as a timedelta object, or timedelta(0) if DST is not in effect. This is purely informational; the DST offset has already been added to @@ -1950,7 +1950,7 @@ def strptime(cls, date_string, format): return _strptime._strptime_datetime(cls, date_string, format) def utcoffset(self): - """Returns the difference between local time and UTC as a timedelta object.""" + """Return the difference between local time and UTC as a timedelta object.""" if self._tzinfo is None: return None offset = self._tzinfo.utcoffset(self) @@ -1971,7 +1971,7 @@ def tzname(self): return name def dst(self): - """Returns the DST offset as a timedelta object, or timedelta(0) if + """Return the DST offset as a timedelta object, or timedelta(0) if DST is not in effect. This is purely informational; the DST offset has already been added to diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 4ba12011d8c10a7..e39ccc584dfd1fc 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -1199,7 +1199,7 @@ call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg) * doesn't return None or timedelta, TypeError is raised and this returns -1. * If utcoffset() returns an out of range timedelta, * ValueError is raised and this returns -1. Else *none is - * set to 0 and the offset from UTC is returned as int # of minutes. + * set to 0 and the offset from UTC is returned as int number of minutes. */ static PyObject * call_utcoffset(PyObject *tzinfo, PyObject *tzinfoarg) @@ -1213,7 +1213,7 @@ call_utcoffset(PyObject *tzinfo, PyObject *tzinfoarg) * doesn't return None or timedelta, TypeError is raised and this * returns -1. If dst() returns an invalid timedelta for a UTC offset, * ValueError is raised and this returns -1. Else *none is set to 0 and - * the offset from local time is returned as an int # of minutes. + * the offset from local time is returned as an int number of minutes. */ static PyObject * call_dst(PyObject *tzinfo, PyObject *tzinfoarg) @@ -3790,11 +3790,11 @@ static PyMethodDef tzinfo_methods[] = { PyDoc_STR("datetime -> string name of time zone.")}, {"utcoffset", (PyCFunction)tzinfo_utcoffset, METH_O, - PyDoc_STR("Returns the difference between local time and UTC as a timedelta " + PyDoc_STR("Return the difference between local time and UTC as a timedelta " "object.")}, {"dst", (PyCFunction)tzinfo_dst, METH_O, - PyDoc_STR("Returns the DST offset as a timedelta object.")}, + PyDoc_STR("Return the DST offset as a timedelta object.")}, {"fromutc", (PyCFunction)tzinfo_fromutc, METH_O, PyDoc_STR("datetime in UTC -> datetime in local time.")}, From 1531bb7d7912156ea7e4fbe8e366754a74843a98 Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Sun, 3 Apr 2022 09:20:31 -0700 Subject: [PATCH 4/5] Missed one "Returns" --- Lib/datetime.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/datetime.py b/Lib/datetime.py index 847080b526a75ef..ce527ab72bd7349 100644 --- a/Lib/datetime.py +++ b/Lib/datetime.py @@ -1123,7 +1123,7 @@ def tzname(self, dt): raise NotImplementedError("tzinfo subclass must override tzname()") def utcoffset(self, dt): - "Returns the difference between local time and UTC as a timedelta object." + "Return the difference between local time and UTC as a timedelta object." raise NotImplementedError("tzinfo subclass must override utcoffset()") def dst(self, dt): From 8bf7479d84cc1193138087e0e8e9cccdd01e91a4 Mon Sep 17 00:00:00 2001 From: slateny <46876382+slateny@users.noreply.github.com> Date: Sun, 3 Apr 2022 09:21:11 -0700 Subject: [PATCH 5/5] Missed "an" --- Modules/_datetimemodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index e39ccc584dfd1fc..96033f32b3b024d 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -1199,7 +1199,7 @@ call_tzinfo_method(PyObject *tzinfo, const char *name, PyObject *tzinfoarg) * doesn't return None or timedelta, TypeError is raised and this returns -1. * If utcoffset() returns an out of range timedelta, * ValueError is raised and this returns -1. Else *none is - * set to 0 and the offset from UTC is returned as int number of minutes. + * set to 0 and the offset from UTC is returned as an int number of minutes. */ static PyObject * call_utcoffset(PyObject *tzinfo, PyObject *tzinfoarg)