Most pregnancy calculators show you a date and hide the arithmetic. This article opens our own
component and shows every computation, including the inputs it refuses and the one thing it
does not ask for. You will be able to reproduce every number on screen with a calendar.
The rule the calculator runs
Our tracker takes one input, the first day of your last menstrual period, and applies fixed
arithmetic in milliseconds:
dueDate = lmp + 280 days
conceptionDate = lmp + 14 days
diffDays = floor((today - lmp) / 1 day)
currentWeek = floor(diffDays / 7)
currentDay = diffDays mod 7
daysRemaining = max(0, 280 - diffDays)
The 280-day rule is the standard Naegele calculation, stated here as industry convention: it
assumes a 28-day cycle with ovulation on day 14, which is also why the conception estimate is
LMP plus 14 days. Our code implements exactly 280, not nine calendar months, so the due date
is always exactly 40 weeks from your input.
A worked example, start to finish
Enter an LMP of 2026-01-05. The due date is 2026-01-05 plus 280 days, which lands on
2026-10-12. The conception estimate is 2026-01-19.
Open the page on 2026-09-24. The elapsed span is 262 days, so the tracker shows week 37 plus 3
days, third trimester, with 18 days remaining. The progress bar sits at 37 divided by 40,
which is 92.5 percent. Every one of those numbers is the arithmetic above, and you can check
each one by hand.
How weeks and trimesters are assigned
Week counting is integer division. At 262 elapsed days you get week 37 with a remainder of 3,
displayed as week 37 and 3 days. Gestational age starts at zero on your LMP date, so week 1
begins on day 7.
Trimester boundaries are two comparisons in the code:
1. Week below 13: first trimester.
2. Week below 27: second trimester.
3. Week 27 and above: third trimester.
That puts weeks 1 to 12 in the first trimester, 13 to 26 in the second, and 27 to 40 in the
third. Note the boundary days themselves: at exactly week 13 the label flips on the same day
your week counter ticks over.
The guard, and what it refuses
The component rejects the input when diffDays is below 0 or above 280. In practice:
- A future LMP date shows the range error instead of a result.
- An LMP more than 280 days ago shows the same error, because the pregnancy has run past the
estimated due date window.
- An empty field simply does nothing until you pick a date.
There is no cycle length input anywhere in the component. This matters and most guides skip
it. If your cycle runs 35 days, ovulation tends to come about a week later than the day-14
assumption, and the fixed 280-day rule shifts your true estimate accordingly. The correction
is deterministic: add your cycle length minus 28 to your LMP date before entering it. With a
35-day cycle and an LMP of 2026-01-05, enter 2026-01-12 instead, and the due date moves from
2026-10-12 to 2026-10-19. A 25-day cycle subtracts 3 days instead.
The milestones list
The tracker shows three fixed milestones from the component: first heartbeat at week 6, gender
determination at week 18, and the viability threshold at week 24. These are hardcoded display
values, so they are the same for every user and every input. Treat all three as approximate
clinical markers to discuss with your provider, not as scheduled events. Your scan schedule
comes from your caregiver, who may date the pregnancy differently after a first-trimester
ultrasound.
One edge case worth knowing
The component parses your date input as UTC midnight, then compares it against the browser's
local clock. In timezones behind UTC, during part of your local day the elapsed-day count can
read one day ahead. If the week counter looks off by a day in the evening, this parsing detail
is why, and the value corrects itself by the next morning. The week number itself is rarely
affected, because a one-day error only matters on the exact boundary between weeks.
A second example with an adjusted cycle
An LMP of 2026-03-01 with a textbook 28-day cycle gives a due date of 2026-12-06. On
2026-09-24 that is 207 elapsed days, week 29 plus 4 days, third trimester, 73 days remaining.
With a 31-day cycle, add 3 days to the input, enter 2026-03-04, and every downstream number
shifts by exactly 3 days. Nothing else changes, because the formulas are pure date arithmetic
with no other variables.
Checklist before you trust the output
- You entered the first day of bleeding, not the last day, as the LMP.
- You adjusted the input by cycle length minus 28 if your cycle is not 28 days.
- You treat the due date as 40 weeks exactly, a convention, not a deadline.
- You read week plus day together, since 37 and 3 is not 38.
- You keep the milestones as discussion points for your appointments.
- You know the guard refuses anything past 280 days, so a post-date pregnancy shows an error
rather than week 41.
The calculator is a calendar, and a good one, but your provider dates pregnancies with
ultrasound measurements that this tool never sees. Use it for orientation between
appointments.
Did your cycle-adjusted date match what your clinic calculated, or did an ultrasound move it?
We want your numbers, because the cycle adjustment is the part worth testing against real
outcomes. Run your dates through our
[pregnancy calculator](https://webrecast.com/en/pregnancy-calculator) and check the week
arithmetic against the worked example above.