from datetime import datetime


def date2juldate(val):
    """Convert from a python date/datetime to a Julian date & time"""
    f = 12 * val.year + val.month - 22803
    fq = f // 12
    fr = f % 12
    dt = (fr * 153 + 302) // 5 + val.day + fq * 1461 // 4
    if isinstance(val, datetime):
        return (
            dt
            + (
                val.hour
                + (val.minute + (val.second + 0.000001 * val.microsecond) / 60.0) / 60.0
            )
            / 24.0
        )
    else:
        return dt