Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix localized datelong on Kodi Android 21 #1189

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading