from aiogram import types from common.constants import DAYS def get_add_homework_keyboard() -> types.InlineKeyboardMarkup: from datetime import date, timedelta today = date.today() buttons = [] for i in range(7): t = today + timedelta(days=i) text = f'{t.day}.{t.month}.{str(t.year)[2:]}' buttons.append(types.InlineKeyboardButton(text=f'{text} ({DAYS[t.weekday()]})', callback_data=f'add_homework_{text}')) keyboard = types.InlineKeyboardMarkup() keyboard.add(*buttons) return keyboard
Public
17.65% issue ratio
L9 Bad design
Seems like things could be organized in a better way.
Why importing inside a function instead of top of module?
L50 Reinventing a wheel
Whatever you want to code, usually someone has already done that. And usually there are some tools to cover your case. And usually you can find them using Google.
Why not using strftime
?
text = t.strftime('%d.%m.%y')
L50 Reinventing a wheel
Whatever you want to code, usually someone has already done that. And usually there are some tools to cover your case. And usually you can find them using Google.
Suggested change:
# DAYS[t.weekday()] t.strftime('%A')
Create new review request