This commit is contained in:
25
utils/helpers.py
Normal file
25
utils/helpers.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
Общие вспомогательные функции
|
||||
"""
|
||||
from datetime import datetime as dt
|
||||
|
||||
|
||||
def create_folder(num: int) -> str:
|
||||
"""
|
||||
Форматирует номер дня/месяца для имени папки (добавляет ведущий ноль)
|
||||
"""
|
||||
if int(num) // 10 == 0:
|
||||
return f"0{num}"
|
||||
else:
|
||||
return str(num)
|
||||
|
||||
|
||||
def get_current_date_parts() -> tuple[str, str, str]:
|
||||
"""
|
||||
Возвращает текущую дату в формате (год, месяц, день) с форматированием
|
||||
"""
|
||||
datetime_now = dt.now()
|
||||
current_day = create_folder(datetime_now.day)
|
||||
current_month = create_folder(datetime_now.month)
|
||||
current_year = f"{datetime_now.year}"
|
||||
return current_year, current_month, current_day
|
||||
Reference in New Issue
Block a user