Пример #1
0
 def finder(value):
     last_weekday = last_day_of_month_for_weekday(value.year, value.month, weekday).day
     if last_weekday > value.day:
         return last_weekday - value.day
     elif last_weekday < value.day:
         next_month = datetime.date(value.year, value.month, 1)
         next_month = replace_month(next_month, diff_month=1)
         last_weekday = last_day_of_month_for_weekday(next_month.year, next_month.month, weekday).day
         month_days = monthrange(value.year, value.month)[1]
         return last_weekday - value.day + month_days
     else:
         return 0
Пример #2
0
 def finder(value):
     nearest = get_nearest(value.month, options, 12)
     if nearest:
         return replace_month(value, diff_month=nearest).replace(day=1, hour=0, minute=0, second=0)