Reputation: 949
I am working with Django. My database has a Schedule
table with the following fields:
startingTime
content DateTimeField
durationInMinits
content IntegerField
It means that any work starts at startingTime
and lasts for durationInMinits
(numeric value, in minute unit).
If a work is started at April 22, 2021, 6 p.m.
and it's durationInMinits
is 30
minutes, then it will running till April 22, 2021, 6:30 p.m
.
I need to determine, does the work running time belong to the current time
?
Here I will determine current time
by using timezone.now()
function. kindly provide any suggestion to determine it.
Upvotes: 1
Views: 77
Reputation: 427
This will send that your current time belongs to your defined range
startingTime <= timezone.now() < startingTime + timezone.timedelta(minutes=durationInMinits)
Upvotes: 2