Write month_end(year, month) returning the last date of that month — leap-February included — using the roll-over trick: day 1 of the next month minus one day. No calendar module.
Examples
Example 1
Input
month_end(2024, 2)
Output
date(2024, 2, 29)
Explanation
2024 is a leap year.
Constraints
No calendar.monthrange.
December must roll into January of the next year.
Topics
Date & Timecalendar math
Companies
OracleSAPDeloitte
Hints
Hint 1
Next month: (month % 12) + 1, bumping the year when month == 12.