Skip to content

Commit

Permalink
Date intervals: allow using other as fallback form
Browse files Browse the repository at this point in the history
Fixes #825
  • Loading branch information
akx committed Jan 25, 2022
1 parent 9a70340 commit 0b606b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion babel/dates.py
Expand Up @@ -948,7 +948,7 @@ def _iter_patterns(a_unit):
pattern = None
for patterns in _iter_patterns(unit):
if patterns is not None:
pattern = patterns[plural_form]
pattern = patterns.get(plural_form) or patterns.get('other')
break
# This really should not happen
if pattern is None:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_date_intervals.py
Expand Up @@ -52,3 +52,13 @@ def test_format_interval_invalid_skeleton():
t2 = TEST_DATE + datetime.timedelta(days=1)
assert dates.format_interval(t1, t2, "mumumu", fuzzy=False, locale="fi") == u"8.1.2016\u20139.1.2016"
assert dates.format_interval(t1, t2, fuzzy=False, locale="fi") == u"8.1.2016\u20139.1.2016"


def test_issue_825():
assert dates.format_timedelta(
datetime.timedelta(hours=1),
granularity='hour',
threshold=100,
format='short',
locale='pt',
) == '1 h'

0 comments on commit 0b606b3

Please sign in to comment.