def _get_local_time(self, timestr):
'''returns the correct localized representation of the time provided by the api'''
result = ""
try:
if timestr and ":" in timestr:
timestr = timestr.replace(".", ":")
if "H" in xbmc.getRegion('time'):
time_format = "HH:mm"
else:
time_format = "h:mm A"
if " AM" in timestr or " PM" in timestr:
result = arrow.get(timestr, 'h:mm A').format(time_format, locale=KODI_LANGUAGE)
elif " am" in timestr or " pm" in timestr:
result = arrow.get(timestr, 'h:mm a').format(time_format, locale=KODI_LANGUAGE)
elif "AM" in timestr or "PM" in timestr:
result = arrow.get(timestr, 'h:mmA').format(time_format, locale=KODI_LANGUAGE)
elif "am" in timestr or "pm" in timestr:
result = arrow.get(timestr, 'h:mma').format(time_format, locale=KODI_LANGUAGE)
elif len(timestr.split(":")[0]) == 1:
result = arrow.get(timestr, 'h:mm').format(time_format, locale=KODI_LANGUAGE)
else:
result = arrow.get(timestr, 'HH:mm').format(time_format, locale=KODI_LANGUAGE)
except Exception as exc:
self._log_msg(str(exc), xbmc.LOGWARNING)
return timestr
return result
评论列表
文章目录