You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
449 B
17 lines
449 B
from datetime import datetime, timedelta
|
|
from collections import Counter
|
|
|
|
|
|
def date_range(start, end):
|
|
if isinstance(start, datetime):
|
|
start = start.date()
|
|
if isinstance(end, datetime):
|
|
end = end.date()
|
|
delta = end - start
|
|
for d in range(delta.days + 1):
|
|
yield start + timedelta(days=d)
|
|
return
|
|
|
|
|
|
def weekdays_in_date_range(start, end):
|
|
return Counter([d.isoweekday() for d in date_range(start, end)])
|
|
|