title: Adding Business Days to Date Field
body: <p>I am trying to add a number of business days to a date field in Django. This is for product ordering where we have different lead times for different products and we want to generated a target date for each product.</p>
  
  <p>for example, product X might take 10 business days to deliver, if this product is ordered on Friday date 01/03/2013 the target date should end up being the Friday 15/03/2013 (it excludes the ordering date as a day).</p>
  
  <p>I have had a look around and there seems to be some python libraries to do this kinda stuff but it all seemed overly complicated. I thought that there would be a fairly simple way to do this.</p>
  
  <p>** EDIT **</p>
  
  <p>I am now using the BusinessHours PyPi package, however seem to be getting some problems.</p>
  
  <p>They give you an example on how to call the package.</p>
  
  <pre><code>eg: Class:  BusinessHours(datetime1,datetime2,worktiming=[9 ,18],weekends=[6,7],holidayfile=None)
  
  Class Parameters:
  datetime1   - The datetime object with the starting date.
  datetime2   - The datetime object with the ending date.
  worktiming  - The working office hours . A list containing two values start time and end time
  weekends    - The days in a week which have to be considered as weekends sent as a list, 1 for monday ...  7 for sunday.
  holidayfile - A file consisting of the predetermined office holidays.Each date starts in a new line and currently must only be in the format dd-mm-yyyy
  
  from BusinessHours import BusinessHours
  from datetime import datetime
  testing = BusinessHours(datetime(2007,10,15),datetime.now())
  print testing.getdays()
  </code></pre>
  
  <p>Using this information I made the below test script</p>
  
  <pre><code>from BusinessHours import BusinessHours
  from datetime import datetime
  holidaytextfile = 'holidays.txt' 
  
  testing = BusinessHours(datetime(2013,02,01),datetime(2013,02,28),worktiming=[9 ,18],weekends=[6,7],holidayfile=holidaytextfile)
  print testing.getdays()
  </code></pre>
  
  <p>My holiday file contains the following (just a random business day in Feb)</p>
  
  <pre><code>07-02-2013
  </code></pre>
  
  <p>When I run the script I get the below error.</p>
  
  <pre><code>Traceback (most recent call last):
  File "business_days", line 9, in ?
  print testing.getdays()
  File "/usr/lib/python2.4/site-packages/BusinessHours.py", line 63, in getdays
  holidate = date(int(year) , int(month) , int(day))
  NameError: global name 'date' is not defined
  </code></pre>
  
  <p>This is the section of code from the package.</p>
  
  <pre><code> 60             for definedholiday in definedholidays:
   61                 flag=0;
   62                 day , month , year = definedholiday.split('-')
   63                 holidate = date(int(year) , int(month) , int(day))
   64                 for weekend in self.weekends:
   65                      #check if mentioned holiday lies in defined weekend , shouldnt deduct twice
   66                     if(holidate.isoweekday==weekend):
   67                         flag=1;
   68                         break;
  </code></pre>
  
  <p>I appreciate any assistance anybody an give me, my Python version is 2.4.3</p>