Python xbmc.getRegion() Examples

The following are 10 code examples of xbmc.getRegion(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmc , or try the search function .
Example #1
Source File: utils.py    From plugin.video.auvio with GNU General Public License v3.0 6 votes vote down vote up
def get_stream_start_date_formatted(start_date):
    
    if start_date is None:
        common.plugin.log_error('utils.get_stream_start_date_formatted() : 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 
Example #2
Source File: utils.py    From service.upnext with GNU General Public License v2.0 5 votes vote down vote up
def localize_time(time):
    """Localize time format"""
    time_format = getRegion('time')

    # Fix a bug in Kodi v18.5 and older causing double hours
    # https://github.com/xbmc/xbmc/pull/17380
    time_format = time_format.replace('%H%H:', '%H:')

    # Strip off seconds
    time_format = time_format.replace(':%S', '')

    return time.strftime(time_format) 
Example #3
Source File: utils.py    From plugin.video.themoviedb.helper with GNU General Public License v3.0 5 votes vote down vote up
def get_region_date(date_obj, region='dateshort', del_fmt=':%S'):
    date_fmt = xbmc.getRegion(region).replace(del_fmt, '')
    return date_obj.strftime(date_fmt) 
Example #4
Source File: contextEPG.py    From plugin.video.iptv.recorder with GNU General Public License v3.0 5 votes vote down vote up
def get_format():
    dateFormat = xbmc.getRegion('datelong')
    timeFormat = xbmc.getRegion('time').replace('%H%H', '%H').replace('%I%I', '%I')
    timeFormat = timeFormat.replace(":%S", "")
    return "{}, {}".format(dateFormat, timeFormat) 
Example #5
Source File: xbmc_context.py    From plugin.video.youtube with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #6
Source File: xbmc_context.py    From plugin.video.youtube with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #7
Source File: gui.py    From FTV-Guide-Repo with GNU General Public License v2.0 5 votes vote down vote up
def formatTime(self, timestamp):
        if timestamp:
            format = xbmc.getRegion('time').replace(':%S', '').replace('%H%H', '%H')
            return timestamp.strftime(format)
        else:
            return '' 
Example #8
Source File: gui.py    From FTV-Guide-Repo with GNU General Public License v2.0 5 votes vote down vote up
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 '' 
Example #9
Source File: kodiutils.py    From plugin.video.vrt.nu with GNU General Public License v3.0 5 votes vote down vote up
def localize_time(time):
    """Localize time format"""
    time_format = xbmc.getRegion('time')

    # Fix a bug in Kodi v18.5 and older causing double hours
    # https://github.com/xbmc/xbmc/pull/17380
    time_format = time_format.replace('%H%H:', '%H:')

    # Strip off seconds
    time_format = time_format.replace(':%S', '')

    return time.strftime(time_format) 
Example #10
Source File: kodiutils.py    From plugin.video.vrt.nu with GNU General Public License v3.0 5 votes vote down vote up
def localize_datelong(date):
    """Return a localized long date string"""
    return localize_date(date, xbmc.getRegion('datelong'))