Created
March 6, 2016 11:54
-
-
Save thombashi/62cc7e921db01b223839 to your computer and use it in GitHub Desktop.
Get working days between two dates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
import datetime | |
import sys | |
from workalendar.asia import Japan | |
def get_total_working_day(cal, start_date, end_date): | |
current_date = start_date | |
working_days = 0 | |
while current_date < end_date: | |
if cal.is_working_day(current_date): | |
working_days += 1 | |
current_date += datetime.timedelta(days=1) | |
return working_days | |
def main(): | |
cal = Japan() | |
print get_total_working_day( | |
cal, datetime.date(2016, 3, 6), datetime.date(2016, 3, 13)) | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment