Use Date Format Settings in Addon?
#1
In the Kodi regional settings it will list the regional date and time formats. You can adjust these or keep whatever the default is for your area. 

I'm wondering if there is a way to tie into these when writing an addon so that you follow the user specified values? I think it would be useful when displaying a date or time to be able to format it in the regional format based on the user's preference setting. I tried looking through the Pydocs, built in function, and JSON-RPC but couldn't find anything that looked like what I needed. I'm guessing it's not available but wanted to check just in case. 

If it doesn't exist something within an addon where you could pass in a datetime or Unix timstamp and get a string formatted in the correct way based on these settings would be awesome. Might need a couple functions like getDate() or getTime() with perhaps some args for the short/long values of each.
Reply
#2
That's what I'm using to convert dates from themoviedb or omdb

Quote:import arrow # -> <import addon="script.module.arrow" version="0.10.0"/>

def date_format(value,date='short'): # or long for long date format
    try:
        date_time = arrow.get(value, 'YYYY-MM-DD') # or use the source format. this is just a example
        value = date_time.strftime(xbmc.getRegion('date%s' % date))

    except Exception:
        pass

    return value
 
Main: Lancool II Mesh  - Ryzen 9 5900x - MSI x570 Unify - Zotac RTX 3080 AMP HOLO - 32GB Trident Z Neo 3600 CL16 -  EVO 960 M.2 250GB / EVO 940 250GB / MX100 512GB /  Crucial P1 2TB / WD Blue 3D Nand 2TB 
Sound: Saxx AS30 DSP - Beyer Dynamic Custom One Pro 
TV: Nvidia Shield 2019 Pro- Adalight 114x LEDs - Sony 65XG9505 - Kodi / Emby - Yamaha RX-V683 - Heco Victa 700/101/251a + Dynavoice Magic FX-4
Server: i3 Skylake - 8GB - OMV4 - 22TB Storage
Reply
#3
(2019-08-19, 19:16)sualfred Wrote: That's what I'm using to convert dates from themoviedb or omdb
Quote:import arrow # -> <import addon="script.module.arrow" version="0.10.0"/>

def date_format(value,date='short'): # or long for long date format
    try:
        date_time = arrow.get(value, 'YYYY-MM-DD') # or use the source format. this is just a example
        value = date_time.strftime(xbmc.getRegion('date%s' % date))

    except Exception:
        pass

    return value
 
Perfect. I had overlooked that one looking for something like getDate() or the like. Thanks!
Reply

Logout Mark Read Team Forum Stats Members Help
Use Date Format Settings in Addon?0