def decimal_relative_time(d, other=None, ndigits=0, cardinalize=True):
 if (other is None):
  other = datetime.utcnow()
 diff = (other - d)
 diff_seconds = total_seconds(diff)
 abs_diff = abs(diff)
 b_idx = (bisect.bisect(_BOUND_DELTAS, abs_diff) - 1)
 (bbound, bunit, bname) = _BOUNDS[b_idx]
 f_diff = (diff_seconds / total_seconds(bunit))
 rounded_diff = round(f_diff, ndigits)
 if cardinalize:
  return (rounded_diff, _cardinalize_time_unit(bname, abs(rounded_diff)))
 return (rounded_diff, bname)

def decimal_relative_time ( d , other = None , ndigits = 0 , cardinalize = True ) : if ( other is None ) : other = datetime . utcnow ( ) diff = ( other - d ) diff_seconds = total_seconds ( diff ) abs_diff = abs ( diff ) b_idx = ( bisect . bisect ( _BOUND_DELTAS , abs_diff ) - 1 ) ( bbound , bunit , bname ) = _BOUNDS [ b_idx ] f_diff = ( diff_seconds / total_seconds ( bunit ) ) rounded_diff = round ( f_diff , ndigits ) if cardinalize : return ( rounded_diff , _cardinalize_time_unit ( bname , abs ( rounded_diff ) ) ) return ( rounded_diff , bname )
get a tuple representing the relative time difference between two :class:~datetime .