|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
|
|
|
|
ISO_8601 = "%Y-%m-%dT%H:%M:%SZ"
|
|
|
|
def iso8601_to_datetime(timestamp: Optional[str]) -> Optional[datetime]:
|
|
if isinstance(timestamp, str):
|
|
return datetime.strptime(timestamp, ISO_8601)
|
|
return timestamp |