diff options
author | Julien Jehannet <julien.jehannet@logilab.fr> | 2010-05-28 11:27:47 +0200 |
---|---|---|
committer | Julien Jehannet <julien.jehannet@logilab.fr> | 2010-05-28 11:27:47 +0200 |
commit | 0f2b6209a5582cd38f3f5d3ca9442629036f5ebf (patch) | |
tree | ac4a58443f3cfc8688602be215b11ef9e8a44f65 /date.py | |
parent | 389ca1dd5c5b09869d3c893ec0d5a76fc75e9408 (diff) | |
download | logilab-common-0f2b6209a5582cd38f3f5d3ca9442629036f5ebf.tar.gz |
Fix nb_open_days() codomain: positive natural numbers are expected
Return only positive natural numbers whatever the number of holiday days in computation.
Diffstat (limited to 'date.py')
-rw-r--r-- | date.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -166,7 +166,10 @@ def nb_open_days(start, end): open_days = weeks * 5 + plus nb_week_holidays = len([x for x in get_national_holidays(start, end+step) if weekday(x) < 5 and x < end]) - return open_days - nb_week_holidays + open_days -= nb_week_holidays + if open_days < 0: + return 0 + return open_days def date_range(begin, end, incday=None, incmonth=None): """yields each date between begin and end |