mathkiler / PSEC

0 stars 0 forks source link

changer façons de changer de jour #146

Open mathkiler opened 6 months ago

mathkiler commented 6 months ago

plutôt que de check à chaque commande d'un jour, go utiliser ce module : https://pypi.org/project/date-time-event/

mathkiler commented 6 months ago

utiliser un thread qui pointe sur une fonction à retardement à peux prèt comme ça :


from date_time_event import Untiltime

def function():
    print('Hello! Its time!', datetime.now())
    # Current datetime with 5 seconds in future.
    date = datetime.now() + timedelta(0, 1)

    th = Untiltime(function, dateOrtime=date)
    # Initializing new date
    th.date = datetime.now() + timedelta(0, 5)
    th.start()

# Current datetime with 5 seconds in future.
date = datetime.now() + timedelta(0, 1)

th = Untiltime(function, dateOrtime=date)
# Initializing new date
th.date = datetime.now() + timedelta(0, 5)
th.start()

print('Function will be call at: %s \n' % th.date)```