Hope what you need. And I hope it is clear.
>>> import math >>> from datetime import * >>> tmp = datetime.today(); >>> static_date = datetime(tmp.year, tmp.month, tmp.day, 22, 5); >>> static_date datetime.datetime(2019, 3, 17, 22, 5) >>> current_date = datetime.today() >>> current_date datetime.datetime(2019, 3, 17, 17, 2, 34, 792760) >>> delta = static_date - current_date >>> delta datetime.timedelta(seconds=18145, microseconds=207240) >>> # Если секунды нужно "отсекать", можно вместо math.ceil() юзать просто int(), тогда и библиотеку лишнюю подключать не придётся. >>> if ( delta.days == -1 ): out_minutes = math.ceil(delta.seconds / 60) - 24 * 60; else: out_minutes = math.ceil(delta.seconds / 60); >>> out_minutes 303 # Количество минут от текущего до заданного >>> test_date = datetime(tmp.year, tmp.month, tmp.day, 23, 35) >>> delta = static_date - test_date >>> delta datetime.timedelta(days=-1, seconds=81000) >>> if ( delta.days == -1 ): out_minutes = math.ceil(delta.seconds / 60) - 24 * 60; else: out_minutes = math.ceil(delta.seconds / 60); >>> out_minutes -90 # Отрицательное число, если текущее время больше заданного
ребуется вычесть из заданного времени, настоящее.
, and in the example you subtract 22 hours and 30 minutes from the current time (i.e., the specified time?). Please provide an example of input and output data. - froxxendsg22.05
, and the current (present)23.35
, i.e. the answer will be negative-90 минут
, how, then, to handle the answer, or is it no longer important? - froxxendsg pm