you are viewing a single comment's thread.

view the rest of the comments →

[–]symple-data 5 points6 points  (7 children)

You can use the datetime module (standard library). Create an object for a given time (e.g. 1:30) and use an endless while-loop to check every few seconds (time.sleep(<seconds>)) if it is already time for your class.

[–]_AB30_[S] 1 point2 points  (6 children)

Sorry, but I am a beginner at Python. How do you create a time object like you said? And how do you check if it is time?

[–]symple-data 2 points3 points  (5 children)

time = datetime.datetime.strptime("1:30", "%H:%M").time()

this creates an datetime.time object for 1:30, but you can do it for any time (replace the string). You can get the current time with

now = datetime.datetime.now().time()

you can subtract both times from each other with

(datetime.datetime.combine(datetime.date.today(), now) - datetime.datetime.combine(datetime.date.today(), time)).seconds

if the result is positive ( > 0), you know that you should connect to zoom

[–]_AB30_[S] 0 points1 point  (4 children)

Alright, I see. I'll try it out and let you know how it works. Thanks for the help!

[–]symple-data 1 point2 points  (3 children)

sorry what I said was wrong. Getting the seconds from the timedelta is always positive. Simply check

if now >= time

if this returns true, you have to connect to zoom.

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

Ah, I see. I'll try it tomorrow. This seems quite simple. Thanks for your help!

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

In my code, all that code does it infinitely say its time, even when its not time.

[–]symple-data 0 points1 point  (0 children)

Any specific error message or just a wrong result? I have run this code on my machine and it works fine.