def JD(d, m, y):
    """Returns Julian Day number for year `y`, month `m`, and day `d`."""
    if m <= 2:
        y -= 1
        m += 12
    if (y, m, d) >= (1582, 10, 15):
        a = int(y / 100)
        b = 2 - a + int(a / 4)
    else:
        b = 0
    jd = int(365.25 * (y + 4716)) + int(30.6001 * (m + 1)) + d + b - 1524.5
    return jd
