date-range

Efficient date range overlap calculation?

Efficient date range overlap calculation? Question: I have two date ranges where each range is determined by a start and end date (obviously, datetime.date instances). The two ranges can overlap or not. I need the number of days of the overlap. Of course I can pre-fill two sets with all dates within both ranges and …

Total answers: 10

Iterating through a range of dates in Python

Iterating through a range of dates in Python Question: I have the following code to do this, but how can I do it better? Right now I think it’s better than nested loops, but it starts to get Perl-one-linerish when you have a generator in a list comprehension. day_count = (end_date – start_date).days + 1 …

Total answers: 25