FMN_bot/src/sheduler.py

16 lines
570 B
Python
Raw Normal View History

import calendar
import datetime
from config import hour_poll_posting
def check_stop_thread_scan(suggested_date):
suggested_month = suggested_date.month
suggested_year = suggested_date.year
tuesdays = []
for i in calendar.Calendar().itermonthdays4(suggested_year, suggested_month):
print(i)
if i[3] == 1 and datetime.datetime(year=i[0], month=i[1], day=i[2]) > suggested_date:
tuesdays.append(datetime.datetime(
year=i[0], month=i[1], day=i[2], hour=hour_poll_posting))
return tuesdays[0] # near tuesday