JosefJezek
7/4/2014 - 11:44 AM

Python Working / Business Days

Python Working / Business Days

Python Working / Business Days

from datetime import datetime, date, time, timedelta
from pandas.tseries.offsets import CustomBusinessDay
from workdays import workday
from czech_holidays import holidays

date_now = datetime.now().date()
time_now = datetime.now().time()
dt_now = datetime.now()

issue_duration_time = timedelta(days=1, hours=5)

bday = CustomBusinessDay(holidays=holidays)
deadline = dt_now + sla * bday - issue_duration_time

deadline2_date = workday(date_now, sla, holidays)
deadline2 = datetime.combine(deadline2_date, time_now) - issue_duration_time
from datetime import datetime, date, time, timedelta
from bizdatetime import *
from czech_holidays import holidays

sla_sec = sla_day * (SLA_TIME_TO - SLA_TIME_FROM) * 3600
sla_delta = sla_sec - issue_duration_time.total_seconds()

sla_policy = Policy(weekends=(SAT, SUN), holidays=holidays, hours=(time(SLA_TIME_FROM), time(SLA_TIME_TO)))

deadline = sla_policy.add_seconds(datetime.now(), sla_delta)

print(deadline.strftime('%Y/%m/%d %H:%M:%S'))