Fix failing test

This commit is contained in:
Kovid Goyal 2025-04-05 10:38:04 +05:30
parent 3b95ee47ba
commit 23187893ba
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 2 deletions

View File

@ -289,7 +289,12 @@ def timestampfromdt(dt, assume_utc=True):
# Format date functions {{{
def fd_format_hour(dt, ampm, hr):
h = int(strftime('%I' if ampm else '%H', t=dt.timetuple()).strip())
try:
h = int(strftime('%I' if ampm else '%H', t=dt.timetuple()).strip())
except Exception:
h = dt.hour
if ampm:
h %= 12
if len(hr) == 1:
return f'{h}'
return f'{h:02}'

View File

@ -82,7 +82,7 @@ def get_ampm_text(which):
else:
d.setHours(13, 0, 0, 0)
x = window.Intl.DateTimeFormat('default', { 'hour': 'numeric', 'hour12': True }).format(d)
ans = get_ampm_text[which] = x.replace(/\d+/g, '').trim()
ans = get_ampm_text[which] = x.replace(/\d+/g, '').trim() or which.toUpperCase()
return ans