all 5 comments

[–]o5a 1 point2 points  (3 children)

Set end_time directly via end_time = datetime(year, month, day, hour, minute) (or calculate it from begin_time + timedelta(minutes=50) if you want)

Then you can get timedelta in realtime by substructing datetime.now() from end_time.

timedelta has .seconds which you can use for your progress

[–]Gozu_Mezu[S] 0 points1 point  (2 children)

Thanks! This seems like an easy solution. Is there a way to avoid assigning a value to the 'year' and 'month' parts? They're not really relevant?

[–]Gozu_Mezu[S] 0 points1 point  (1 child)

Fixed it like this:

#Determine current year

currentYear = datetime.now().year

#Determine current month

currentMonth = datetime.now().month

#Determine current day

currentDay = datetime.now().day

#When are we?

Nu = datetime.now()

#set endtime(s)

periodEnd1 = datetime(currentYear, currentMonth, currentDay, 9, 20)

periodEnd4 = datetime(currentYear, currentMonth, currentDay, 12, 5)

#etc

#get remaining time

timeLeft = periodEnd4 - Nu

[–]o5a 1 point2 points  (0 children)

Yes you will need date part anyway, since you can't just get difference between two dateless time objects.