python类getRegion()的实例源码

utils.py 文件源码 项目:plugin.video.auvio 作者: rickybiscus 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def get_stream_start_date_formatted(start_date):

    if start_date is None:
        common.plugin.log_error('utils.is_live_media() : missing start_date')
        return None

    now_datetime = now()
    start_date = dateutil.parser.parse(start_date)

    formatted_date = start_date.strftime(xbmc.getRegion('dateshort'))
    formatted_time = start_date.strftime(xbmc.getRegion('time'))

    if now_datetime.date() != start_date.date():
        formatted_datetime = formatted_date + " - " + formatted_time
    else:
        formatted_datetime = formatted_time

    return formatted_datetime
thetvdb.py 文件源码 项目:script.module.thetvdb 作者: marcelveldt 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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
thetvdb.py 文件源码 项目:script.module.thetvdb 作者: marcelveldt 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _get_local_date(datestr, long_date=False):
        '''returns the localized representation of the date provided by the api'''
        result = ""
        try:
            if long_date:
                result = arrow.get(datestr).strftime(xbmc.getRegion('datelong'))
            else:
                result = arrow.get(datestr).strftime(xbmc.getRegion('dateshort'))
        except Exception as exc:
            _log_msg("Exception in _get_local_date: %s" % exc)
        return result
gui.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def formatTime(self, timestamp):
        if timestamp:
            format = xbmc.getRegion('time').replace(':%S', '').replace('%H%H', '%H')
            return timestamp.strftime(format)
        else:
            return ''
gui.py 文件源码 项目:script.tvguide.fullscreen 作者: primaeval 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def formatDate(self, timestamp, longdate=False):
        if timestamp:
            if longdate == True:
                format = xbmc.getRegion('datelong')
            else:
                format = xbmc.getRegion('dateshort')
            return timestamp.strftime(format)
        else:
            return ''
utils.py 文件源码 项目:script.module.metadatautils 作者: marcelveldt 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def localized_date_time(timestring):
    '''returns localized version of the timestring (used in pvr)'''
    date_time = arrow.get(timestring)
    local_date = date_time.strftime(xbmc.getRegion("dateshort"))
    local_time = date_time.strftime(xbmc.getRegion("time").replace(":%S", ""))
    return (local_date, local_time)
xbmc_context.py 文件源码 项目:plugin.video.youtube 作者: jdf76 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def format_date_short(self, date_obj):
        date_format = xbmc.getRegion('dateshort')
        _date_obj = date_obj
        if isinstance(_date_obj, datetime.date):
            _date_obj = datetime.datetime(_date_obj.year, _date_obj.month, _date_obj.day)

        return _date_obj.strftime(date_format)
xbmc_context.py 文件源码 项目:plugin.video.youtube 作者: jdf76 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def format_time(self, time_obj):
        time_format = xbmc.getRegion('time')
        _time_obj = time_obj
        if isinstance(_time_obj, datetime.time):
            _time_obj = datetime.time(_time_obj.hour, _time_obj.minute, _time_obj.second)

        return _time_obj.strftime(time_format)
xbmc_context.py 文件源码 项目:plugin.video.youtube 作者: Kolifanes 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def format_date_short(self, date_obj):
        date_format = xbmc.getRegion('dateshort')
        _date_obj = date_obj
        if isinstance(_date_obj, datetime.date):
            _date_obj = datetime.datetime(_date_obj.year, _date_obj.month, _date_obj.day)
            pass

        return _date_obj.strftime(date_format)
xbmc_context.py 文件源码 项目:plugin.video.youtube 作者: Kolifanes 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def format_time(self, time_obj):
        time_format = xbmc.getRegion('time')
        _time_obj = time_obj
        if isinstance(_time_obj, datetime.time):
            _time_obj = datetime.time(_time_obj.hour, _time_obj.minute, _time_obj.second)
            pass

        return _time_obj.strftime(time_format)
default.py 文件源码 项目:kodi-telekomsport 作者: hubsif 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def prettydate(dt, addtime=True):
    dt = dt + utc_offset()
    if addtime:
        return dt.strftime(xbmc.getRegion("datelong") + ", " + xbmc.getRegion("time").replace(":%S", "").replace("%H%H", "%H"))
    else:
        return dt.strftime(xbmc.getRegion("datelong"))


问题


面经


文章

微信
公众号

扫码关注公众号