MCPcopy Index your code
hub / github.com/RustPython/RustPython / fromisoformat

Method fromisoformat

Lib/_pydatetime.py:1040–1055  ·  view source on GitHub ↗

Construct a date from a string in ISO 8601 format.

(cls, date_string)

Source from the content-addressed store, hash-verified

1038
1039 @classmethod
1040 def fromisoformat(cls, date_string):
1041 """Construct a date from a string in ISO 8601 format."""
1042
1043 if not isinstance(date_string, str):
1044 raise TypeError('Argument must be a str')
1045
1046 if not date_string.isascii():
1047 raise ValueError('Argument must be an ASCII str')
1048
1049 if len(date_string) not in (7, 8, 10):
1050 raise ValueError(f'Invalid isoformat string: {date_string!r}')
1051
1052 try:
1053 return cls(*_parse_isoformat_date(date_string))
1054 except Exception:
1055 raise ValueError(f'Invalid isoformat string: {date_string!r}')
1056
1057 @classmethod
1058 def fromisocalendar(cls, year, week, day):

Calls 5

isinstanceFunction · 0.85
lenFunction · 0.85
_parse_isoformat_dateFunction · 0.85
clsClass · 0.50
isasciiMethod · 0.45