Strictly before, not equal
transcript
A subscription expires on day five. The grace period is zero. Is it expired on day five?
Three subscriptions expire on days three, five and eight. Today is day five. Only day three is strictly before it. So one subscription is expired.
Search for the cutoff itself. That counts one subscription. Search for one more and it counts two. Day five is still valid today.
Expired means strictly before the day. Add the grace to the expiry. A lower bound counts them.
Grace is a promise to the customer. Their access stays on. It ends only after the grace.
Say the rule in words first. Expiry plus grace is before the day. Then write the comparison.
Test an expiry equal to the day. Test a day before every expiry. Test a day after every expiry.
Billing runs on every day. A sorted index answers fast. An off-by-one costs real money.
Search for the cutoff itself. Full breakdown in the lecture.