Skip to content

Commit 5b2924d

Browse files
committed
Add documentation links to datetime strftime/strptime docstrings
- Add links to format codes documentation for all strftime methods - Add links to format codes documentation for all strptime methods - Addresses issue #97517
1 parent f19f1d8 commit 5b2924d

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

Lib/_pydatetime.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,10 @@ def fromisocalendar(cls, year, week, day):
10721072

10731073
@classmethod
10741074
def strptime(cls, date_string, format):
1075-
"""Parse string according to the given date format (like time.strptime())."""
1075+
"""Parse string according to the given date format (like time.strptime()).
1076+
For a list of supported format codes, see the documentation:
1077+
https://docs.python.org/3/library/datetime.html#format-codes
1078+
"""
10761079
import _strptime
10771080
return _strptime._strptime_datetime_date(cls, date_string, format)
10781081

@@ -1109,6 +1112,8 @@ def strftime(self, format):
11091112
Format using strftime().
11101113
11111114
Example: "%d/%m/%Y, %H:%M:%S"
1115+
For a list of supported format codes, see the documentation:
1116+
https://docs.python.org/3/library/datetime.html#format-codes
11121117
"""
11131118
return _wrap_strftime(self, format, self.timetuple())
11141119

@@ -1456,8 +1461,12 @@ def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold
14561461
return self
14571462

14581463
@classmethod
1464+
14591465
def strptime(cls, date_string, format):
1460-
"""Parse string according to the given time format (like time.strptime())."""
1466+
"""Parse string according to the given time format (like time.strptime()).
1467+
For a list of supported format codes, see the documentation:
1468+
https://docs.python.org/3/library/datetime.html#format-codes
1469+
"""
14611470
import _strptime
14621471
return _strptime._strptime_datetime_time(cls, date_string, format)
14631472

@@ -1650,6 +1659,8 @@ def fromisoformat(cls, time_string):
16501659
def strftime(self, format):
16511660
"""Format using strftime(). The date part of the timestamp passed
16521661
to underlying strftime should not be used.
1662+
For a list of supported format codes, see the documentation:
1663+
https://docs.python.org/3/library/datetime.html#format-codes
16531664
"""
16541665
# The year must be >= 1000 else Python's strftime implementation
16551666
# can raise a bogus exception.
@@ -2198,7 +2209,10 @@ def __str__(self):
21982209

21992210
@classmethod
22002211
def strptime(cls, date_string, format):
2201-
"""Parse string according to the given date and time format (like time.strptime())."""
2212+
"""Parse string according to the given time format (like time.strptime()).
2213+
For a list of supported format codes, see the documentation:
2214+
https://docs.python.org/3/library/datetime.html#format-codes
2215+
"""
22022216
import _strptime
22032217
return _strptime._strptime_datetime_datetime(cls, date_string, format)
22042218

0 commit comments

Comments
 (0)