diff --git a/resources/lib/helper/__init__.py b/resources/lib/helper/__init__.py index beb06035..5575306f 100644 --- a/resources/lib/helper/__init__.py +++ b/resources/lib/helper/__init__.py @@ -16,6 +16,7 @@ from utils import write_xml from utils import compare_version from utils import unzip from utils import create_id +from utils import convert_to_local as Local from wrapper import progress from wrapper import catch diff --git a/resources/lib/helper/utils.py b/resources/lib/helper/utils.py index b20bdd5f..4a1dd3e8 100644 --- a/resources/lib/helper/utils.py +++ b/resources/lib/helper/utils.py @@ -17,6 +17,7 @@ import xbmcgui import xbmcvfs from . import _ +from libraries.dateutil import tz, parser ################################################################################################# @@ -444,3 +445,19 @@ def split_list(itemlist, size): ''' Split up list in pieces of size. Will generate a list of lists ''' return [itemlist[i:i+size] for i in range(0, len(itemlist), size)] + +def convert_to_local(date): + + ''' Convert the local datetime to local. + ''' + date = convert_str_to_date(date) if type(date) in (unicode, str) else date + date = date.replace(tzinfo=tz.tzutc()) + date = date.astimezone(tz.tzlocal()) + + return date.strftime('%Y-%m-%dT%H:%M:%S') + +def convert_str_to_date(date): + + ''' Convert string to date. + ''' + return parser.parse(date)