Skip to content
20 changes: 17 additions & 3 deletions Lib/_pydatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,10 @@ def fromisocalendar(cls, year, week, day):

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

Expand Down Expand Up @@ -1109,6 +1112,8 @@ def strftime(self, format):
Format using strftime().

Example: "%d/%m/%Y, %H:%M:%S"
For a list of supported format codes, see the documentation:
https://docs.python.org/3/library/datetime.html#format-codes
"""
return _wrap_strftime(self, format, self.timetuple())

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

@classmethod

def strptime(cls, date_string, format):
"""Parse string according to the given time format (like time.strptime())."""
"""Parse string according to the given time format (like time.strptime()).
For a list of supported format codes, see the documentation:
https://docs.python.org/3/library/datetime.html#format-codes
"""
import _strptime
return _strptime._strptime_datetime_time(cls, date_string, format)

Expand Down Expand Up @@ -1650,6 +1659,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.
For a list of supported format codes, see the documentation:
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 @@ -2198,7 +2209,10 @@ def __str__(self):

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

Expand Down
Loading