aboutsummaryrefslogtreecommitdiff
path: root/challenge-259/eric-cheung/python/ch-1.py
blob: 794b79e0297da512e69be02f0f63d3b4e3ae1ed0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from datetime import datetime, timedelta

strDateFormat = "%Y-%m-%d"

## Example 1
## strStartDate = "2018-06-28"
## nOffset = 3
## arrBankHoliday = ["2018-07-03"]

## Example 2
strStartDate = "2018-06-28"
nOffset = 3
arrBankHoliday = []

objOutputDate = datetime.strptime(strStartDate, strDateFormat)

while nOffset > 0:
    objOutputDate = objOutputDate + timedelta(days = 1)
    if objOutputDate.weekday() < 5 and not objOutputDate.strftime(strDateFormat) in arrBankHoliday:
        nOffset = nOffset - 1

print (objOutputDate.strftime(strDateFormat))