Prep convert to local time

This commit is contained in:
angelblue05 2018-12-30 19:34:45 -06:00
parent 47f7d99954
commit 358a029700
2 changed files with 18 additions and 0 deletions

View file

@ -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

View file

@ -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)