From df69f96a924104d9ee2a14d64498d7c9005e3ac3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 5 Apr 2025 10:55:03 +0530 Subject: [PATCH] Another try at fixing the failing test --- src/pyj/date.pyj | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pyj/date.pyj b/src/pyj/date.pyj index ec7727a829..279ac8d782 100644 --- a/src/pyj/date.pyj +++ b/src/pyj/date.pyj @@ -76,13 +76,17 @@ def fd_format_timezone(dt, ampm, t, as_utc): def get_ampm_text(which): ans = get_ampm_text[which] if not ans: - d = Date() - if which is 'am': - d.setHours(1, 0, 0, 0) - 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() or which.toUpperCase() + try: + d = Date() + if which is 'am': + d.setHours(1, 0, 0, 0) + else: + d.setHours(13, 0, 0, 0) + x = window.Intl.DateTimeFormat('default', { 'hour': 'numeric', 'hour12': True }).format(d) + ans = x.replace(/\d+/g, '').trim() or which.toUpperCase() + except: + ans = which.toUpperCase() + get_ampm_text[which] = ans return ans