Skip to content

gh-97517: Add hyperlink to format code information for strftime() and strptime() docstrings. #132375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Lib/_pydatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,8 @@ def strftime(self, format):
Format using strftime().

Example: "%d/%m/%Y, %H:%M:%S"

`A list of supported format codes can be viewed here. <https://docs.python.org/3/library/datetime.html#format-codes>`_
"""
return _wrap_strftime(self, format, self.timetuple())

Expand Down Expand Up @@ -1636,6 +1638,8 @@ def fromisoformat(cls, time_string):
def strftime(self, format):
"""Format using strftime(). The date part of the timestamp passed
to underlying strftime should not be used.

`A list of supported format codes can be viewed here. <https://docs.python.org/3/library/datetime.html#format-codes>`_
"""
# The year must be >= 1000 else Python's strftime implementation
# can raise a bogus exception.
Expand Down Expand Up @@ -2180,7 +2184,9 @@ def __str__(self):

@classmethod
def strptime(cls, date_string, format):
'string, format -> new datetime parsed from a string (like time.strptime()).'
"""string, format -> new datetime parsed from a string (like time.strptime()).

`A list of supported format codes can be viewed here. <https://docs.python.org/3/library/datetime.html#format-codes>`_"""
import _strptime
return _strptime._strptime_datetime_datetime(cls, date_string, format)

Expand Down
Loading