From 190fd6042f022e86249d4b51cf1c4cfa6d8fa8c0 Mon Sep 17 00:00:00 2001 From: mediaminister Date: Tue, 1 Oct 2024 13:53:08 +0200 Subject: [PATCH] Fix localized datelong on Kodi Android 21 --- resources/lib/kodiutils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/resources/lib/kodiutils.py b/resources/lib/kodiutils.py index c8a1ad9e..f2790309 100644 --- a/resources/lib/kodiutils.py +++ b/resources/lib/kodiutils.py @@ -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) @@ -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)