Fix the days until renewal countdown
Your task
Your billing page shows how many whole days are left until a subscription renews. The first version mixed a UTC renewal time with the server's local clock. The new version takes both times as UTC strings, so the result does not depend on where the server runs.
An assistant wrote days_until_renewal(renewal_utc, now_utc). It is in the editor. It has a bug. Find it and fix it.
Input and output:
renewal_utc: when the subscription renews.now_utc: the current time.- Both are UTC times written
YYYY-MM-DDTHH:MM:SS, sometimes with a trailingZ. TheZchanges nothing. Years are from 2000 to 2100. - Return the number of whole days from
now_utctorenewal_utc, as an integer.
Rules the tests check:
- Take the difference in seconds,
renewal_utcminusnow_utc, using real calendar dates with leap years. - Divide by 86400, the seconds in a day, and drop the fraction. The result rounds toward zero on both sides: a renewal 5 hours away is 0 days, and a renewal 5 hours in the past is also 0, not -1.
Examples
days_until_renewal(renewal_utc: str, now_utc: str) -> intExample 1
Input
days_until_renewal("2026-02-05T08:30:00Z", "2026-01-31T08:30:00Z")Output
5Example 2
Input
days_until_renewal("2026-01-31T13:30:00Z", "2026-01-31T08:30:00Z")Output
0Example 3
Input
days_until_renewal("2026-01-31T03:30:00Z", "2026-01-31T08:30:00Z")Output
0