coco_apm_reporting_accmgmt/src/dtaccountapi/utils.py

11 lines
276 B
Python

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