summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorPaul Ganssle <pganssle@users.noreply.github.com>2019-04-29 13:22:03 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-04-29 13:22:03 (GMT)
commit88c093705615c50c47fdd9ab976803f73de7e308 (patch)
tree4a76496a2c930d1e27e020555f4b91e2b43f777b /Doc
parenta86e06433a010f873dfd7957e0f87a39539876ee (diff)
downloadcpython-88c093705615c50c47fdd9ab976803f73de7e308.zip
cpython-88c093705615c50c47fdd9ab976803f73de7e308.tar.gz
cpython-88c093705615c50c47fdd9ab976803f73de7e308.tar.bz2
bpo-36004: Add date.fromisocalendar (GH-11888)
This commit implements the first version of date.fromisocalendar, the inverse function for date.isocalendar.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/datetime.rst17
-rw-r--r--Doc/whatsnew/3.8.rst10
2 files changed, 27 insertions, 0 deletions
diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst
index 1ee23c2..abdc977 100644
--- a/Doc/library/datetime.rst
+++ b/Doc/library/datetime.rst
@@ -458,6 +458,13 @@ Other constructors, all class methods:
.. versionadded:: 3.7
+.. classmethod:: date.fromisocalendar(year, week, day)
+
+ Return a :class:`date` corresponding to the ISO calendar date specified by
+ year, week and day. This is the inverse of the function :meth:`date.isocalendar`.
+
+ .. versionadded:: 3.8
+
Class attributes:
@@ -854,6 +861,16 @@ Other constructors, all class methods:
.. versionadded:: 3.7
+
+.. classmethod:: datetime.fromisocalendar(year, week, day)
+
+ Return a :class:`datetime` corresponding to the ISO calendar date specified
+ by year, week and day. The non-date components of the datetime are populated
+ with their normal default values. This is the inverse of the function
+ :meth:`datetime.isocalendar`.
+
+ .. versionadded:: 3.8
+
.. classmethod:: datetime.strptime(date_string, format)
Return a :class:`.datetime` corresponding to *date_string*, parsed according to
diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst
index 225faf8..ac57335 100644
--- a/Doc/whatsnew/3.8.rst
+++ b/Doc/whatsnew/3.8.rst
@@ -244,6 +244,16 @@ where the DLL is stored (if a full or partial path is used to load the initial
DLL) and paths added by :func:`~os.add_dll_directory`.
+datetime
+--------
+
+Added new alternate constructors :meth:`datetime.date.fromisocalendar` and
+:meth:`datetime.datetime.fromisocalendar`, which construct :class:`date` and
+:class:`datetime` objects respectively from ISO year, week number and weekday;
+these are the inverse of each class's ``isocalendar`` method.
+(Contributed by Paul Ganssle in :issue:`36004`.)
+
+
gettext
-------