# Path: django_toolkit/date_util.py
# def business_days(start, stop):
#     """
#     Return business days between two inclusive dates - ignoring public holidays.
#     
#     Note that start must be less than stop or else 0 is returned.
#     
#     @param start: Start date
#     @param stop: Stop date
#     @return int
#     """
#     dates=rrule.rruleset()
#     # Get dates between start/stop (which are inclusive)
#     dates.rrule(rrule.rrule(rrule.DAILY, dtstart=start, until=stop))
#     # Exclude Sat/Sun 
#     dates.exrule(rrule.rrule(rrule.DAILY, byweekday=(rrule.SA, rrule.SU), dtstart=start)) 
#     return dates.count()
# 
# Path: django_toolkit/date_util.py
# def days(start, stop):
#     """
#     Return days between start & stop (inclusive)
#     
#     Note that start must be less than stop or else 0 is returned.
#     
#     @param start: Start date
#     @param stop: Stop date
#     @return int
#     """
#     dates=rrule.rruleset()
#     # Get dates between start/stop (which are inclusive)
#     dates.rrule(rrule.rrule(rrule.DAILY, dtstart=start, until=stop))
#     return dates.count()


from datetime import datetime, timedelta
from dateutil import rrule, relativedelta
from django_toolkit.date_util import business_days as dt_business_days
from django_toolkit.date_util import days as dt_days
    Given a date, return a date first day of the month.
    
    @param dt: The date to base the return value upon.
    @param d_years: Specify a delta in years to apply to date.
    @param d_months: Specify a delta in months to apply to date.
    
    @see http://code.activestate.com/recipes/476197-first-last-day-of-the-month/
    """
    y, m = dt.year + d_years, dt.month + d_months
    a, m = divmod(m-1, 12)
    return datetime(y+a, m+1, 1)

def end_of_month(dt):
    """
    Given a date, return the last day of the month.
    
    @param dt: The date to base the return value upon.
    """
    return start_of_month(dt, 0, 1) + timedelta(-1)

def business_days(start, stop):
    """
    Return business days between two datetimes (inclusive).
    """
    return dt_business_days(start.date(), stop.date())

def days(start, stop):
    """
    Return days between two datetimes (inclusive).
    """

# Path: django_toolkit/date_util.py
# def business_days(start, stop):
#     """
#     Return business days between two inclusive dates - ignoring public holidays.
#     
#     Note that start must be less than stop or else 0 is returned.
#     
#     @param start: Start date
#     @param stop: Stop date
#     @return int
#     """
#     dates=rrule.rruleset()
#     # Get dates between start/stop (which are inclusive)
#     dates.rrule(rrule.rrule(rrule.DAILY, dtstart=start, until=stop))
#     # Exclude Sat/Sun 
#     dates.exrule(rrule.rrule(rrule.DAILY, byweekday=(rrule.SA, rrule.SU), dtstart=start)) 
#     return dates.count()
# 
# Path: django_toolkit/date_util.py
# def days(start, stop):
#     """
#     Return days between start & stop (inclusive)
#     
#     Note that start must be less than stop or else 0 is returned.
#     
#     @param start: Start date
#     @param stop: Stop date
#     @return int
#     """
#     dates=rrule.rruleset()
#     # Get dates between start/stop (which are inclusive)
#     dates.rrule(rrule.rrule(rrule.DAILY, dtstart=start, until=stop))
#     return dates.count()


# Path: django_toolkit/datetime_util.py
from datetime import datetime, timedelta
from dateutil import rrule, relativedelta
from django_toolkit.date_util import business_days as dt_business_days
from django_toolkit.date_util import days as dt_days

    Given a date, return a date first day of the month.
    
    @param dt: The date to base the return value upon.
    @param d_years: Specify a delta in years to apply to date.
    @param d_months: Specify a delta in months to apply to date.
    
    @see http://code.activestate.com/recipes/476197-first-last-day-of-the-month/
    """
    y, m = dt.year + d_years, dt.month + d_months
    a, m = divmod(m-1, 12)
    return datetime(y+a, m+1, 1)

def end_of_month(dt):
    """
    Given a date, return the last day of the month.
    
    @param dt: The date to base the return value upon.
    """
    return start_of_month(dt, 0, 1) + timedelta(-1)

def business_days(start, stop):
    """
    Return business days between two datetimes (inclusive).
    """
    return dt_business_days(start.date(), stop.date())

def days(start, stop):
    """
    Return days between two datetimes (inclusive).
    """

    return dt_days(start.date(), stop.date())