from datetime import datetime


def create_nav_btn(soup,date,text):
    """
    Helper functions for month_calendar, generates a navigation button
    for calendar

    :param soup: BeautifulSoup parser of document
    :param date: Date to create nav button
    :param text: Text for button
    """
    nav_th = soup.new_tag('th',attrs=[('colspan','2')])
    nav_th['class'] = 'month'
    nav_a = soup.new_tag('a',href='/apps/orders/%s/%s' % (date.year,
                                                          date.month))
    nav_a.string = text
    if date > datetime.today():
        nav_a['class'] = "btn btn-mini btn-info disabled"
        nav_a['href'] = '#'
    else:
        nav_a['class'] = "btn btn-mini btn-info"
    nav_th.insert(0,nav_a)
    return nav_th