def _to_ordinalf(dt):
 tzi = getattr(dt, u'tzinfo', None)
 if (tzi is not None):
  dt = dt.astimezone(UTC)
  tzi = UTC
 base = float(dt.toordinal())
 cdate = getattr(dt, u'date', (lambda : None))()
 if (cdate is not None):
  midnight_time = datetime.time(0, tzinfo=tzi)
  rdt = datetime.datetime.combine(cdate, midnight_time)
  base += ((dt - rdt).total_seconds() / SEC_PER_DAY)
 return base

def _to_ordinalf ( dt ) : tzi = getattr ( dt , u'tzinfo' , None ) if ( tzi is not None ) : dt = dt . astimezone ( UTC ) tzi = UTC base = float ( dt . toordinal ( ) ) cdate = getattr ( dt , u'date' , ( lambda : None ) ) ( ) if ( cdate is not None ) : midnight_time = datetime . time ( 0 , tzinfo = tzi ) rdt = datetime . datetime . combine ( cdate , midnight_time ) base += ( ( dt - rdt ) . total_seconds ( ) / SEC_PER_DAY ) return base
convert :mod:datetime or :mod:date to the gregorian date as utc float days .