mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-06-18 22:26:14 +00:00
Add tests for helper.utils.convert_to_local
This commit is contained in:
parent
5f8865de49
commit
8d5df4cc10
2 changed files with 84 additions and 9 deletions
|
@ -483,8 +483,16 @@ def convert_to_local(date):
|
|||
date = date.replace(tzinfo=tz.tzutc())
|
||||
date = date.astimezone(tz.tzlocal())
|
||||
# Bad metadata defaults to date 1-1-1. Catch it and don't throw errors
|
||||
if date.year == 1:
|
||||
return str(date)
|
||||
if date.year < 1900:
|
||||
# FIXME(py2): strftime don't like dates below 1900
|
||||
return "{:04d}-{:02d}-{:02d}T{:02d}:{:02d}:{:02d}".format(
|
||||
date.year,
|
||||
date.month,
|
||||
date.day,
|
||||
date.hour,
|
||||
date.minute,
|
||||
date.second,
|
||||
)
|
||||
else:
|
||||
return date.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
except Exception as error:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue