fixed bug ##206 bug fix that the

This commit is contained in:
Tim Gröger 2020-03-01 21:44:38 +01:00
parent c52eca58c5
commit 708ecb1aa6
1 changed files with 16 additions and 8 deletions

View File

@ -78,17 +78,25 @@ class UserController(metaclass=Singleton):
def getLockedDay(self, date): def getLockedDay(self, date):
now = datetime.now() now = datetime.now()
daysInMonth = calendar.monthrange(date.year, date.month)[1] oldMonth = False
startMonth = 1
for i in range(1, 8): for i in range(1, 8):
if datetime(date.year, date.month, i).weekday() == 2: if datetime(now.year, now.month, i).weekday() == 2:
startMonth = i if now.day < i:
oldMonth = True
break break
if date.year <= now.year and date.month <= now.month: lockedYear = date.year
for i in range(startMonth, daysInMonth + 1): lockedMonth = date.month if date.month < now.month else now.month - 1 if oldMonth else now.month
self.setLockedDay(datetime(date.year, date.month, i), True) daysInMonth = calendar.monthrange(lockedYear, lockedMonth)[1]
startDay = 1
for i in range(1, 8): for i in range(1, 8):
nextMonth = datetime(date.year, date.month + 1, i) if datetime(lockedYear, lockedMonth, i).weekday() == 2:
startDay = i
break
if lockedYear <= now.year and lockedMonth <= now.month:
for i in range(startDay, daysInMonth + 1):
self.setLockedDay(datetime(lockedYear, lockedMonth, i), True)
for i in range(1, 8):
nextMonth = datetime(lockedYear, lockedMonth + 1, i)
if nextMonth.weekday() == 2: if nextMonth.weekday() == 2:
break break
self.setLockedDay(nextMonth, True) self.setLockedDay(nextMonth, True)