Why can't you subtract two temporary objects? For example, 12:00 - 11:00 = 1:00
from datetime import time time(12,00) - time(11,00) # -> timedelta(hours=1)
It seems to be datetime.time.__sub__missing
datetime.time.__sub__
TypeError: unsupported operand type (s) for -: 'datetime.time' and 'datetime.time'
Do you know why?
time , , , 12:00 () 11:00 Tue, 25 , ( 24 ). , , ( datetime), . :.
time
12:00
11:00
datetime
import datetime def timediff(t1, t2): td = datetime.date.today() return datetime.datetime.combine(td, t1) - datetime.datetime.combine(td, t2)
t1 = time(12, 0) t2 = time(11, 0) td = timedelta(hours=t1.hour-t2.hour, minutes=t1.minute-t2.minute)
Source: https://habr.com/ru/post/1728771/More articles:iPhone - Scrolling UITableView for Indexing - indexingCan we have nested objects in Dojo? - dojoRunning a job every x minutes with startCalendarInterval in launchd (e.g. using * * x step values in cron)? - cronГде я могу найти "Первое время здесь"? Компонент JavaScript на веб-сайте StackOverflow? - javascriptModal box + check box + cookie - javascriptWeb Development Clustering Algorithms - algorithmclose batch file automatically - batch-filePHP error Unable to use return> value method in write context - phpDrawing a point using OpenGL, but not in immediate mode - user-interfacefonts not embedded Flash CS4 AS3 - flashAll Articles