def months_and_days_from_pennies(pennies, discount=False): if discount: year_pennies = get_discounted_price(g.gold_year_price).pennies month_pennies = get_discounted_price(g.gold_month_price).pennies else: year_pennies = g.gold_year_price.pennies month_pennies = g.gold_month_price.pennies if pennies >= year_pennies: years = pennies / year_pennies months = 12 * years days = 366 * years else: months = pennies / month_pennies days = 31 * months return (months, days)