diff options
Diffstat (limited to 'challenge-259/eric-cheung/python/ch-1.py')
| -rwxr-xr-x | challenge-259/eric-cheung/python/ch-1.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-259/eric-cheung/python/ch-1.py b/challenge-259/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..794b79e029 --- /dev/null +++ b/challenge-259/eric-cheung/python/ch-1.py @@ -0,0 +1,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))
|
