refactor: add strict type hints to weekday utility functions (#36057)
This commit is contained in:
parent
3e6c38e661
commit
e3ffbf8c6d
1 changed files with 2 additions and 2 deletions
|
|
@ -524,7 +524,7 @@ def get_first_day_of_week(dt: DateTimeLikeObject, as_str=False) -> datetime.date
|
|||
return date.strftime(DATE_FORMAT) if as_str else date
|
||||
|
||||
|
||||
def get_week_start_offset_days(dt):
|
||||
def get_week_start_offset_days(dt: datetime.date | datetime.datetime) -> int:
|
||||
current_day_index = get_normalized_weekday_index(dt)
|
||||
start_of_week_index = get_start_of_week_index()
|
||||
|
||||
|
|
@ -534,7 +534,7 @@ def get_week_start_offset_days(dt):
|
|||
return 7 - (start_of_week_index - current_day_index)
|
||||
|
||||
|
||||
def get_normalized_weekday_index(dt):
|
||||
def get_normalized_weekday_index(dt: datetime.date | datetime.datetime) -> int:
|
||||
# starts Sunday with 0
|
||||
return (dt.weekday() + 1) % 7
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue