def ordinal_float(dt):
try:<EOL><INDENT>return dt.toordinal() + ((((dt.microsecond / <NUM_LIT>) + dt.second) / <NUM_LIT> + dt.minute) / <NUM_LIT> + dt.hour) / <NUM_LIT><EOL><DEDENT>except AttributeError:<EOL><INDENT>try:<EOL><INDENT>return ordinal_float(make_datetime(dt))<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>dt = list(make_datetime(val) for val in dt)<EOL>assert(all(isinstance(val, datetime.datetime) for val in dt))<EOL>return [ordinal_float(val) for val in dt]<EOL>
Like datetime.ordinal, but rather than integer allows fractional days (so float not ordinal at all)

    Similar to the Microsoft Excel numerical representation of a datetime object

    >>> ordinal_float(datetime.datetime(1970, 1, 1))
    719163.0
    >>> ordinal_float(datetime.datetime(1, 2, 3, 4, 5, 6, 7))  # doctest: +ELLIPSIS
    34.1702083334143...