Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Author: SunGyo Kim
- # Email: Kimsg1984@gmail.com
- # irc.freenode #ubuntu-ko Sungyo
- import calendar
- import datetime
- def calculate_workday(day):
- today = datetime.datetime.now()
- next_workday = today + datetime.timedelta(days=day)
- weekday = (today + datetime.timedelta(days=day)).isoweekday()
- if weekday > 5:
- return next_workday + datetime.timedelta(days=2)
- else:
- return next_workday
- print(calculate_workday(3))
- print(calculate_workday(4))
- print(calculate_workday(5))
- ##############################
- # 2017-12-21 17:27:37.734379
- # 2017-12-22 17:27:37.734452
- # 2017-12-25 17:27:37.734477
- # [Finished in 0.0s]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement