mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix failing test
This commit is contained in:
parent
3b95ee47ba
commit
23187893ba
@ -289,7 +289,12 @@ def timestampfromdt(dt, assume_utc=True):
|
|||||||
# Format date functions {{{
|
# Format date functions {{{
|
||||||
|
|
||||||
def fd_format_hour(dt, ampm, hr):
|
def fd_format_hour(dt, ampm, hr):
|
||||||
|
try:
|
||||||
h = int(strftime('%I' if ampm else '%H', t=dt.timetuple()).strip())
|
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:
|
if len(hr) == 1:
|
||||||
return f'{h}'
|
return f'{h}'
|
||||||
return f'{h:02}'
|
return f'{h:02}'
|
||||||
|
@ -82,7 +82,7 @@ def get_ampm_text(which):
|
|||||||
else:
|
else:
|
||||||
d.setHours(13, 0, 0, 0)
|
d.setHours(13, 0, 0, 0)
|
||||||
x = window.Intl.DateTimeFormat('default', { 'hour': 'numeric', 'hour12': True }).format(d)
|
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
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user