πŸ› οΈToolsShed

Menstrual Cycle Calculator

Predict your next period and fertile window based on cycle length and last period date.

A menstrual cycle calculator helps you track and predict your period dates, fertile window, and ovulation day based on your average cycle length and the date your last period began. Most menstrual cycles last between 21 and 35 days, with 28 days being the commonly cited average β€” but every person's cycle is unique, and this tool adapts to your individual pattern.

To use the calculator, enter the start date of your last period and your average cycle length. The tool will predict your next period date, your estimated ovulation day (typically around day 14 of a 28-day cycle), and your fertile window β€” the days when pregnancy is most likely. You can also track multiple future cycles at once.

While this calculator provides useful estimates for planning and awareness, cycle length can vary due to stress, illness, exercise, or hormonal changes. For medical decisions β€” especially regarding fertility or contraception β€” consult a healthcare provider.

Frequently Asked Questions

Code Implementation

from datetime import date, timedelta

def menstrual_cycle(last_period: date, cycle_length: int = 28, period_length: int = 5) -> dict:
    """
    Predict next period and fertile window based on cycle data.
    Ovulation assumed at cycle_length - 14 days (luteal phase = 14 days).
    """
    ovulation_day = cycle_length - 14
    next_period = last_period + timedelta(days=cycle_length)
    ovulation_date = last_period + timedelta(days=ovulation_day)
    fertile_start = ovulation_date - timedelta(days=5)
    fertile_end = ovulation_date

    return {
        "last_period":    last_period.strftime("%Y-%m-%d"),
        "next_period":    next_period.strftime("%Y-%m-%d"),
        "ovulation_date": ovulation_date.strftime("%Y-%m-%d"),
        "fertile_window": f"{fertile_start.strftime('%Y-%m-%d')} to {fertile_end.strftime('%Y-%m-%d')}",
        "period_ends":    (last_period + timedelta(days=period_length - 1)).strftime("%Y-%m-%d"),
    }

result = menstrual_cycle(date(2025, 3, 1), cycle_length=28, period_length=5)
print(f"Last Period    : {result['last_period']}")
print(f"Period Ends    : {result['period_ends']}")
print(f"Fertile Window : {result['fertile_window']}")
print(f"Ovulation      : {result['ovulation_date']}")
print(f"Next Period    : {result['next_period']}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.