|
@@ -37,16 +37,6 @@ class Kind(IntEnum):
|
|
|
NO_TARGET = 2
|
|
|
NO_TARGET_MAYBE = 3
|
|
|
|
|
|
-class WordKind(IntEnum):
|
|
|
- FIRST = 0 # «год» / «день».
|
|
|
- SECOND = 1 # «лет» / «дней».
|
|
|
- THIRD = 2 # «года» / «дня».
|
|
|
-
|
|
|
-WORDS_TABLE = {
|
|
|
- 'год': ('год', 'лет', 'года'),
|
|
|
- 'день': ('день', 'дней', 'дня')
|
|
|
-}
|
|
|
-
|
|
|
def parse_command(text):
|
|
|
text = text.strip()
|
|
|
|
|
@@ -117,30 +107,6 @@ def parse_kind(kind):
|
|
|
|
|
|
return kind
|
|
|
|
|
|
-# Bruh?
|
|
|
-def get_word_kind(number):
|
|
|
- if number >= 100:
|
|
|
- number %= 100
|
|
|
-
|
|
|
- if number == 0 or 5 <= number <= 20:
|
|
|
- return WordKind.SECOND
|
|
|
-
|
|
|
- last_digit = number % 10
|
|
|
-
|
|
|
- if last_digit == 0:
|
|
|
- return WordKind.SECOND
|
|
|
-
|
|
|
- if last_digit == 1:
|
|
|
- return WordKind.FIRST
|
|
|
-
|
|
|
- if 5 <= last_digit <= 9:
|
|
|
- return WordKind.SECOND
|
|
|
-
|
|
|
- return WordKind.THIRD
|
|
|
-
|
|
|
-def get_word_for(word, number):
|
|
|
- return f'{number} {WORDS_TABLE[word][get_word_kind(number)]}'
|
|
|
-
|
|
|
def calculate_age(date):
|
|
|
now = datetime.now().date()
|
|
|
birthday_date = date.replace(year=now.year)
|