Skip to content
Snippets Groups Projects
Commit fd377e99 authored by Martin Mareš's avatar Martin Mareš
Browse files

util_format: inflect_with_number()

Poměrně často potřebujeme podle čísla ohýbat jak předchozí, tak
následující část fráze.
parent b0505359
Branches
No related tags found
1 merge request!36Vylepšení výsledkové listiny
......@@ -24,6 +24,15 @@ def inflect_by_number(n: int, w1: str, w234: str, wother: str, unitprefix: str =
return f'{unitprefix}{wother}'
def inflect_with_number(n: int, w1: str, w234: str, wother: str) -> str:
if n == 1:
return w1 % n
elif 2 <= n <= 4:
return w234 % n
else:
return wother % n
def timeformat(dt: datetime) -> str:
if dt is None:
return ''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment