Skip to content

Commit

Permalink
Fix localized datelong on Kodi Android 21 (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister authored Oct 1, 2024
1 parent 93e0a1f commit 1dcc67f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion resources/lib/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ def localize_time(time):
def localize_date(date, strftime):
"""Return a localized date, even if the system does not support your locale"""
has_locale = set_locale()

# Workaround for Kodi xbmc.getRegion('datelong') bug on Android 21 and higher: https://github.com/xbmc/xbmc/issues/25066
if xbmc.getCondVisibility('System.Platform.Android') and kodi_version_major() > 20:
strftime = strftime.replace('%-d', date.strftime('%d').lstrip('0'))

# When locale is supported, return original format
if has_locale:
return date.strftime(strftime)
Expand All @@ -446,7 +451,7 @@ def localize_date(date, strftime):

# %e isn't supported on Python 2.7 on Windows
if '%e' in strftime:
strftime = strftime.replace('%e', str(int(date.strftime('%d'))))
strftime = strftime.replace('%e', date.strftime('%d').lstrip('0'))

return date.strftime(strftime)

Expand Down

0 comments on commit 1dcc67f

Please sign in to comment.