-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimeline-generator.py
51 lines (37 loc) · 1.89 KB
/
timeline-generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta, TH, SA
import calendar
def get_quarter_end_date(year, quarter):
quarter_end_month = {1: 3, 2: 6, 3: 9, 4: 12}
month = quarter_end_month[quarter]
day = calendar.monthrange(year, month)[1]
return datetime(year, month, day)
def get_next_weekday(date, weekdays):
# weekdays is a list of integers where Monday is 0 and Sunday is 6
days_ahead = (min((weekday - date.weekday()) % 7 for weekday in weekdays) + 7) % 7
return date + timedelta(days=days_ahead)
def generate_milestones(year, quarter):
milestones = {}
cycle_start_date = get_quarter_end_date(year, quarter)
milestones["Cycle Start Date"] = cycle_start_date
submission_deadline = get_next_weekday(cycle_start_date + timedelta(days=7), [1])
milestones["Submission Deadline"] = submission_deadline
presentation_time = submission_deadline + relativedelta(weekday=TH(+1))
milestones["Presentation Time"] = presentation_time.replace(hour=15, minute=0)
distribution_deadline = presentation_time + timedelta(hours=24)
milestones["Distribution Deadline"] = distribution_deadline
snapshot_date = presentation_time + relativedelta(weekday=SA(+1))
milestones["Snapshot Date"] = snapshot_date
payout_date = snapshot_date + timedelta(days=5)
milestones["Payout Date"] = payout_date
return milestones
def format_milestones(milestones):
formatted_milestones = {key: f"{value.strftime('%A, %Y-%m-%d %H:%M:%S')}" for key, value in milestones.items()}
return formatted_milestones
# Prompt user for input
year = int(input("Enter the year: "))
quarter = int(input("Enter the quarter (1-4): "))
milestones = generate_milestones(year, quarter)
formatted_milestones = format_milestones(milestones)
for milestone, date in formatted_milestones.items():
print(f"{milestone}: {date}")