초기화
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import math
|
||||
from datetime import date, timedelta
|
||||
|
||||
def calculate_end_date(start_date_str: str, work_days: float, works_on_saturday: bool, works_on_sunday: bool) -> str:
|
||||
"""주말(토/일) 근무 여부 플래그를 고려하여 가동 후 실제 종료 날짜(YYYY-MM-DD)를 계산합니다."""
|
||||
start_date = date.fromisoformat(start_date_str)
|
||||
work_days_required = math.ceil(work_days)
|
||||
|
||||
current_date = start_date
|
||||
days_counted = 0
|
||||
if work_days_required <= 0:
|
||||
return start_date.isoformat()
|
||||
|
||||
while days_counted < work_days_required:
|
||||
weekday = current_date.weekday() # 월요일 0, 일요일 6
|
||||
|
||||
is_working_day = True
|
||||
if weekday == 5: # 토요일
|
||||
if not works_on_saturday:
|
||||
is_working_day = False
|
||||
elif weekday == 6: # 일요일
|
||||
if not works_on_sunday:
|
||||
is_working_day = False
|
||||
|
||||
if is_working_day:
|
||||
days_counted += 1
|
||||
|
||||
if days_counted < work_days_required:
|
||||
current_date += timedelta(days=1)
|
||||
|
||||
return current_date.isoformat()
|
||||
Reference in New Issue
Block a user