]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Use `... if expr else ...`
authorJun Omae <jun66j5@gmail.com>
Tue, 10 May 2022 08:01:45 +0000 (17:01 +0900)
committerJun Omae <jun66j5@gmail.com>
Tue, 10 May 2022 08:01:45 +0000 (17:01 +0900)
babel/dates.py

index c79e9cf632fabe6b8d6224158fbb535df17c2e3c..0b37323475548b569d77d5fb8d1155699c1931f1 100644 (file)
@@ -1483,7 +1483,7 @@ class DateTimeFormat(object):
         widths = [{3: 'abbreviated', 4: 'wide', 5: 'narrow'}[max(3, num)],
                   'wide', 'narrow', 'abbreviated']
         if char == 'a':
-            period = {0: 'am', 1: 'pm'}[int(self.value.hour >= 12)]
+            period = 'pm' if self.value.hour >= 12 else 'am'
             context = 'format'
         else:
             period = get_period_id(self.value, locale=self.locale)