Auto-translated
Grigoriy, it's not a very good idea to post a hundred lines of code and ask people to find the error in it. For starters, just add print statements in each function and inside each if statement.
I'll keep that in mind for the future, thank you. In the meantime, the script is working as it should; I just needed to place the trigger for the new day after the function, not before it. It's quite interesting.