def xldate_as_datetime(xldate, datemode):
 if datemode:
  epoch = epoch_1904
 elif (xldate < 60):
  epoch = epoch_1900
 else:
  epoch = epoch_1900_minus_1
 days = int(xldate)
 fraction = (xldate - days)
 seconds = int(round((fraction * 86400000.0)))
 (seconds, milliseconds) = divmod(seconds, 1000)
 return (epoch + datetime.timedelta(days, seconds, 0, milliseconds))

def xldate_as_datetime ( xldate , datemode ) : if datemode : epoch = epoch_1904 elif ( xldate < 60 ) : epoch = epoch_1900 else : epoch = epoch_1900_minus_1 days = int ( xldate ) fraction = ( xldate - days ) seconds = int ( round ( ( fraction * 86400000.0 ) ) ) ( seconds , milliseconds ) = divmod ( seconds , 1000 ) return ( epoch + datetime . timedelta ( days , seconds , 0 , milliseconds ) )
convert an excel date/time number into a :class:datetime .