Calendar math relies on modular (remainder) arithmetic for cycles like the 7-day week, and on a three-part leap year rule to keep the 365-day calendar aligned with Earth's roughly 365.2422-day orbit.
Reading time
— 5 min
Updated
— Aug 16, 2026
Fact-reviewed
— Aug 16, 2026
Key Takeaways
Key Takeaways
1Finding a day of the week in the future or past is modular arithmetic in disguise — days cycle every 7, so you only need the remainder after dividing by 7, not a full day-by-day count.
2The Gregorian calendar's leap year rule has three parts, not one: divisible by 4, except century years, except when also divisible by 400 — this exists to correct a small but real drift.
3Elapsed-time math (age, durations, deadlines) needs care at unit boundaries, since months hold different numbers of days and years may or may not include a February 29th.
The concept
Calendar math is really just counting, but the tricky parts come from things that repeat in cycles rather than counting up forever. Days of the week repeat every 7 days, so "100 days from now" isn't a day you count out one by one — you can shortcut it by finding how many full weeks fit into 100 days and how many days are left over. Leap years are the other main wrinkle: most years have 365 days, but every 4th year usually gets an extra day (February 29th) to keep our calendar in sync with how long Earth actually takes to orbit the sun.
The leap year rule's three parts sound like unnecessary complexity until you check a few real years against it and see exactly why "every year divisible by 4" alone gets it wrong.
Quick check
Was the year 1900 a leap year under the Gregorian calendar rule?
Worked examples
Example 1: Finding the day of the week 100 days from a Wednesday (baseline case)
Today is Wednesday, and you want to know the day of the week 100 days from now. Instead of counting 100 individual days, divide 100 by 7: 100 ÷ 7 = 14 remainder 2 (14 full weeks plus 2 extra days). Fourteen full weeks land back on a Wednesday, and then 2 more days move it to Friday. So 100 days from a Wednesday is a Friday — the same answer you'd get counting day by day, reached in two steps instead of a hundred.
Example 2: Checking whether 2024, 1900, and 2100 are leap years (edge case / variation)
Apply the three-part rule to each: 2024 — divisible by 4 (2024 ÷ 4 = 506) and not a century year, so it's a leap year (it was: February 2024 had 29 days). 1900 — divisible by 4, but also a century year (divisible by 100) and not divisible by 400 (1900 ÷ 400 = 4.75), so the century exception removes it — not a leap year. 2100 — divisible by 4, a century year (2100 ÷ 100 = 21), and not divisible by 400 (2100 ÷ 400 = 5.25), so like 1900, the exception applies and 2100 will not be a leap year, despite being divisible by 4. Three different years, three applications of the exact same three-part test, two different outcomes for the "divisible by 4" years depending purely on the century exception.
Quick check
Will the year 2100 be a leap year under the Gregorian calendar rule?
Example 3: Counting days until a deadline that crosses a month boundary (real-world / applied case)
Today is March 20th, and a bill is due April 15th. March has 31 days, so there are 31 − 20 = 11 days remaining in March, plus all 15 days of April up to and including the 15th: 11 + 15 = 26 days until the deadline. The common error here is forgetting that months have different lengths (28, 29, 30, or 31 days) and either using a flat "30 days per month" estimate or miscounting whether the start or end date should be included — a deadline calculation that's off by even one day, from an inclusive/exclusive counting mistake, can mean paying a bill a day late.
How it works (visual)
The leap year rule as a decision flowchart
Tracing 2024 through the flowchart: divisible by 4, not divisible by 100 — leap year, exiting at the second box. Tracing 1900: divisible by 4, divisible by 100, not divisible by 400 — not a leap year, exiting at the bottom of the third box. Tracing 2000: divisible by 4, divisible by 100, and divisible by 400 — leap year, exiting at the top of the third box. Only century years ever reach that third question at all; every other year that's divisible by 4 exits as a leap year at the second box without needing the century check.
Common mistakes
Common Mistakes
✕
Assuming every year divisible by 4 is a leap year, without checking the century exception.
→ Add the two extra checks for century years: divisible by 100 removes the leap year, unless it's also divisible by 400, which restores it (as with 2000).
✕
Counting elapsed days between two dates by assuming every month has 30 days.
→ Use each month's actual day count (28/29, 30, or 31) — a flat 30-day assumption introduces errors of up to 3 days per month crossed.
✕
Miscounting whether the start date, end date, or both should be included in a day count (an 'off-by-one' error).
→ Decide explicitly whether the range is inclusive or exclusive before counting, and stay consistent — 'from March 20 to April 15' commonly means counting the days after March 20 through April 15 inclusive, as in the worked example above.
Common misconception
“Any year divisible by 4 is a leap year.”
Divisibility by 4 is necessary but not sufficient. Century years (divisible by 100) are the exception — they are not leap years unless they're also divisible by 400. That's why 1900 and 2100 are not leap years despite being divisible by 4, while 2000 was a leap year because it's divisible by both 100 and 400. This three-part rule exists because a plain 4-year cycle slightly overcorrects Earth's true ~365.2422-day orbital period.
Quick check
Which of these three years is NOT a leap year: 2000, 2024, or 2100?
Try it yourself
Day-of-week calculator (modular arithmetic)
Resulting day index (0=Sun...6=Sat)5
What to do next
What to do next
Try the calculator above with today's weekday and a deadline day-count to figure out what day of the week a future date falls on.
Run the three-part leap year test on a year that matters to you (your birth year, a milestone year) to confirm whether it was or will be a leap year.
Next time you're counting days to a deadline across a month boundary, use each month's real day count instead of a flat 30-day estimate.
Practice the modular shortcut (remainder after dividing by 7) instead of manually counting out multi-week spans day by day.
FAQ
FAQ
Related terms
Related terms
Modular arithmetic
Arithmetic that 'wraps around' after reaching a fixed number (the modulus) — clock and calendar cycles, like the 7-day week, are everyday examples.
Leap year
A year with an extra day (February 29) added to keep the 365-day calendar year aligned with Earth's actual orbital period of about 365.2422 days.
Gregorian calendar
The calendar system in near-universal civil use today, introduced in 1582 to correct drift that had built up under the earlier Julian calendar.
Remainder
What's left over after dividing one number by another as many whole times as possible — the basis of modular arithmetic (e.g., 100 ÷ 7 leaves a remainder of 2).