Answer the question
In order to leave comments, you need to log in
How to make the right time intervals?
There is a script. In a certain period of time, the rate should be 10, in another period 12.
The problem is the following: how to make a night time period so that it automatically moves out the next day after 24:00.
When I put the time span like this
today_3am = datetime.today().replace(hours=3, minute=0)
today_8pm = datetime.today().replace(hours=20, minute=0)
if datetime.now() > today_8pm and datetime.now() < today_3am:
return 0.5
Answer the question
In order to leave comments, you need to log in
So you add a day according to the condition when initializing separately today_3am and separately today_8pm
If the user's time is more than 20:00, then add a day today_3am.
If the user's time is less than 3:00, then today_8pm subtract the day.
Well, something like this
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question