def time_to_float(datetimeobject, totalturn=24, minimum=0.0, maximum=1.0):
    """
    Function that returns a float between minimum
    and maximum for a moment within totalturn hours (default: 24)
    00:00 (Midnight) returns a value of 0, 12:00 (Midday) a value of 0.5
    """
    micro = datetimeobject.microsecond / 1000000.0
    sec = datetimeobject.second
    minutes = datetimeobject.minute * 60
    hours = datetimeobject.hour % totalturn * 60 * 60
    currentsecond = hours + minutes + sec + micro
    return minimum + currentsecond / 86400.0 * float(maximum)
