Created
October 3, 2025 14:29
-
-
Save antonvh/f94e54d1b7daf4d137e6be70069ad7c5 to your computer and use it in GitHub Desktop.
Create iterations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Create iterations for a year, sprints Mo-Su | |
| ## Starting on the first Monday of the year | |
| ## 6 sprints per quarter, last sprint is 3 weeks. | |
| ## Possible improvements: also create the AzDo iterations for the year itself and the quarters WITHOUT OVERLAPPING DATES. | |
| ## e.g. 2026 starts on on Jan 6, and Q1 2026 runs from Jan 6 until April 6 2026 | |
| import datetime | |
| def generate_sprints(year=2026): | |
| sprints = [] | |
| start_date = datetime.date(year, 1, 1) | |
| # Find the first Monday of the year | |
| while start_date.weekday() != 0: # 0 represents Monday | |
| start_date += datetime.timedelta(days=1) | |
| sprint_lengths_weeks = [2, 2, 2, 2, 2, 3] | |
| sprint_id_counter = 1 | |
| for quarter in range(1, 5): | |
| for i in range(len(sprint_lengths_weeks)): | |
| sprint_length_weeks = sprint_lengths_weeks[i] | |
| end_date = start_date + datetime.timedelta(weeks=sprint_length_weeks) - datetime.timedelta(days=1) | |
| # Calculate the week range for the title | |
| start_week = start_date.isocalendar()[1] | |
| end_week = end_date.isocalendar()[1] | |
| # Handle cases where the sprint crosses the year boundary | |
| if end_week < start_week and end_date.year == year: | |
| end_week = datetime.date(year, 12, 31).isocalendar()[1] | |
| title = f"Sprint {sprint_id_counter:02d}, Q{quarter} {year} (wk {start_week}-{end_week})" | |
| sprints.append({ | |
| "id": sprint_id_counter, | |
| "title": title, | |
| "start_date": start_date.strftime("%Y-%m-%d"), | |
| "end_date": end_date.strftime("%Y-%m-%d"), | |
| "capacity": 10 | |
| }) | |
| start_date = end_date + datetime.timedelta(days=1) | |
| sprint_id_counter += 1 | |
| return sprints | |
| sprints = generate_sprints(2025) | |
| sprints.extend(generate_sprints(2026)) # Use extend to add elements from the list | |
| for sprint in sprints: | |
| print(sprint) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment