MCPcopy Create free account
hub / github.com/encode/starlette / DateTimeConvertor

Class DateTimeConvertor

tests/test_convertors.py:22–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20
21
22class DateTimeConvertor(Convertor[datetime]):
23 regex = "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]+)?"
24
25 def convert(self, value: str) -> datetime:
26 return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S")
27
28 def to_string(self, value: datetime) -> str:
29 return value.strftime("%Y-%m-%dT%H:%M:%S")
30
31
32@pytest.fixture(scope="function")

Callers 1

appFunction · 0.85

Calls

no outgoing calls

Tested by 1

appFunction · 0.68