mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-08 00:28:16 -06:00
Handle naive datetimes gracefully
This commit is contained in:
parent
07ad4c1c9c
commit
409564091d
@ -219,7 +219,8 @@ def isodate(value):
|
|||||||
text = value.isoformat()
|
text = value.isoformat()
|
||||||
return mark_safe(f'<span title="{naturalday(value)}">{text}</span>')
|
return mark_safe(f'<span title="{naturalday(value)}">{text}</span>')
|
||||||
elif type(value) is datetime.datetime:
|
elif type(value) is datetime.datetime:
|
||||||
text = localtime(value).date().isoformat()
|
local_value = localtime(value) if value.tzinfo else value
|
||||||
|
text = local_value.date().isoformat()
|
||||||
return mark_safe(f'<span title="{naturaltime(value)}">{text}</span>')
|
return mark_safe(f'<span title="{naturaltime(value)}">{text}</span>')
|
||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
@ -230,7 +231,8 @@ def isotime(value, spec='seconds'):
|
|||||||
if type(value) is datetime.time:
|
if type(value) is datetime.time:
|
||||||
return value.isoformat(timespec=spec)
|
return value.isoformat(timespec=spec)
|
||||||
if type(value) is datetime.datetime:
|
if type(value) is datetime.datetime:
|
||||||
return localtime(value).time().isoformat(timespec=spec)
|
local_value = localtime(value) if value.tzinfo else value
|
||||||
|
return local_value.time().isoformat(timespec=spec)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user