Commits

Jun Omae  committed e733aa9

Fixed broken date/time hint when locale which '%p' is empty (e.g. LANG=de_DE.UTF-8)

  • Participants
  • Parent commits 75a0a71

Comments (0)

Files changed (1)

File trac/util/datefmt.py

 
     t = datetime(1999, 10, 29, 23, 59, 58, tzinfo=utc)
     tmpl = format_datetime(t, tzinfo=utc)
-    return tmpl.replace(format_time(t, '%p', tzinfo=utc), 'a') \
-               .replace('1999', 'YYYY', 1).replace('99', 'YY', 1) \
+    ampm = format_time(t, '%p', tzinfo=utc)
+    if ampm:
+        tmpl = tmpl.replace(ampm, 'a')
+    return tmpl.replace('1999', 'YYYY', 1).replace('99', 'YY', 1) \
                .replace('10', 'MM', 1).replace('29', 'DD', 1) \
                .replace('23', 'hh', 1).replace('11', 'hh', 1) \
                .replace('59', 'mm', 1).replace('58', 'ss', 1)
 
     t = datetime(1999, 10, 29, 23, 59, 58, tzinfo=utc)
     tmpl = format_time(t, tzinfo=utc)
-    return tmpl.replace(format_time(t, '%p', tzinfo=utc), 'TT') \
-               .replace('23', 'hh', 1).replace('11', 'hh', 1) \
+    ampm = format_time(t, '%p', tzinfo=utc)
+    if ampm:
+        tmpl = tmpl.replace(ampm, 'a')
+    return tmpl.replace('23', 'hh', 1).replace('11', 'hh', 1) \
                .replace('59', 'mm', 1).replace('58', 'ss', 1) \