Original Question: Я хочу сравнить список часов и минут с текущем временем и найти ближайший час и минуты из списка. Помогите реализовать?
у меня есть алгоритм только для даты, а как сделать тоже самое для моего вопроса
алгоритм:
English Translation: I want to compare a list of hours and minutes with the current time and find the nearest hour and minutes from the list. Can you help me to implement it?
I have an algorithm for date only, but how to do the same for my question
Algorithm:
date_list = ['2025-02-10', '2025-01-13', '2025-02-8']
datetime_list = [datetime.strptime(date, "%Y-%m-%d")
for date in date_list]
today = datetime.today()
date_diffs = [abs(date - today) for date in datetime_list]
closest_date = date_list[date_diffs.index(min(date_diffs))
Подробнее здесь: https://stackoverflow.com/questions/783 ... rrent-time