platypush/platypush/schemas/__init__.py

11 lines
240 B
Python
Raw Normal View History

2021-07-22 01:02:15 +02:00
from datetime import datetime
from typing import Optional
def normalize_datetime(dt: str) -> Optional[datetime]:
if not dt:
return
if dt.endswith('Z'):
dt = dt[:-1] + '+00:00'
return datetime.fromisoformat(dt)