Advertisement
SunGyo

Untitled

Dec 18th, 2017
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. # Author: SunGyo Kim
  5. # Email: Kimsg1984@gmail.com
  6. # irc.freenode #ubuntu-ko Sungyo
  7.  
  8. import calendar
  9. import datetime
  10.  
  11. def calculate_workday(day):
  12.     today = datetime.datetime.now()
  13.     next_workday = today + datetime.timedelta(days=day)
  14.     weekday = (today + datetime.timedelta(days=day)).isoweekday()
  15.     if weekday > 5:
  16.         return next_workday + datetime.timedelta(days=2)
  17.     else:
  18.         return next_workday
  19.  
  20. print(calculate_workday(3))
  21. print(calculate_workday(4))
  22. print(calculate_workday(5))
  23. ##############################
  24. # 2017-12-21 17:27:37.734379
  25. # 2017-12-22 17:27:37.734452
  26. # 2017-12-25 17:27:37.734477
  27. # [Finished in 0.0s]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement