diff options
| author | Dave Jacoby <jacoby.david@gmail.com> | 2024-03-06 12:20:54 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-06 12:20:54 -0500 |
| commit | c2236d751700d5f259791a9218696e934c6bebdc (patch) | |
| tree | 49838dee91b2ad0a2c5b22ad8de0937bd68d6111 /challenge-259/eric-cheung/python/ch-1.py | |
| parent | dd68c49c478d198ce7f22ec6961fe4d0bb77376e (diff) | |
| parent | 38ae28aaeacfc9dd53e892f94d5e83d4a83395d2 (diff) | |
| download | perlweeklychallenge-club-c2236d751700d5f259791a9218696e934c6bebdc.tar.gz perlweeklychallenge-club-c2236d751700d5f259791a9218696e934c6bebdc.tar.bz2 perlweeklychallenge-club-c2236d751700d5f259791a9218696e934c6bebdc.zip | |
Merge branch 'manwar:master' into master
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))
|
