Convert ListItem.Premiered in to a different format.
#1
In my addon I'm retrieving ListItem.Premiered and need to convert it into a different format. I'm not sure of the best way to handle this.

The problem is as far as I can see there is no easy way to know what the starting format of ListItem.Premiered is to initially build the python datetime object, as I don't know what region and date format the end user is going to have Kodi set to. Does Kodi give you a way to retrieve the date format in python?
Reply
#2
As far as I could find it's supposed be YYYY-MM-DD at all times. (I don't think any locale ever writes YYYY-DD-MM)
That being said I don't know if anything actually enforces that, so could have time/be in a different format (ISO, etc) and more.
You probably want to use something like Arrow to read the date(/time) instead of manually using strptime
Reply
#3
(2023-08-04, 10:34)mrsix Wrote: As far as I could find it's supposed be YYYY-MM-DD at all times. (I don't think any locale ever writes YYYY-DD-MM)

I'm talking about the format of the date returned by ListItem.Premiered.

With my Kodi locale set to UK I get a value returned as 'DD/MM/YYYY'. If I then set it to US I get 'MM/DD/YYYY' so I'm not sure why you think it should be 'YYYY-MM-DD' at all times.
Reply
#4
I'm not quite sure what you try to accomplish, but you can get the current regional date format from:
python:

xbmc.getRegion('dateshort')
xbmc.getRegion('datelong')
Would that be what you are looking for?
Check the docs for all available formats.
Reply
#5
(2023-08-04, 17:08)kereltje Wrote: xbmc.getRegion('dateshort')
xbmc.getRegion('datelong')
Thanks, I'll take a look at that.
Quote:Check the docs for all available formats.
Could you link the docs you mention, I can't finds them, all I can find is https://alwinesch.github.io/group__pytho...0db6a8505f which doesn't list the formats.
Reply
#6
from the very link you posted:

Note:
    choices are (dateshort, datelong, time, meridiem, tempunit, speedunit) You can use the above as keywords for arguments."
Reply
#7
Sorry my mistake, when you said check docs for available formats I thought you meant date formats ie %d/%m./%Y what I think you meant was check docs for available ID's.

Thanks though, that was exactly what I was looking for.
Reply

Logout Mark Read Team Forum Stats Members Help
Convert ListItem.Premiered in to a different format.0