Rework how the discount code expiration date is calculated to fix #2804