|
|
@ -142,11 +142,14 @@ def enum(typ): |
|
|
|
return _f |
|
|
|
|
|
|
|
|
|
|
|
# TODO: make lazy |
|
|
|
def lazy_datetime(data): |
|
|
|
if not data: |
|
|
|
return property(lambda: None) |
|
|
|
return None |
|
|
|
|
|
|
|
if isinstance(data, int): |
|
|
|
return real_datetime.utcfromtimestamp(data) |
|
|
|
|
|
|
|
def get(): |
|
|
|
for fmt in DATETIME_FORMATS: |
|
|
|
try: |
|
|
|
return real_datetime.strptime(data.rsplit('+', 1)[0], fmt) |
|
|
@ -154,8 +157,6 @@ def lazy_datetime(data): |
|
|
|
continue |
|
|
|
raise ValueError('Failed to conver `{}` to datetime'.format(data)) |
|
|
|
|
|
|
|
return property(get) |
|
|
|
|
|
|
|
|
|
|
|
def datetime(data): |
|
|
|
if not data: |
|
|
|