def _sqlite_format_dtdelta(conn, lhs, rhs):
 try:
  if isinstance(lhs, int):
   lhs = str((decimal.Decimal(lhs) / decimal.Decimal(1000000)))
  real_lhs = parse_duration(lhs)
  if (real_lhs is None):
   real_lhs = backend_utils.typecast_timestamp(lhs)
  if isinstance(rhs, int):
   rhs = str((decimal.Decimal(rhs) / decimal.Decimal(1000000)))
  real_rhs = parse_duration(rhs)
  if (real_rhs is None):
   real_rhs = backend_utils.typecast_timestamp(rhs)
  if (conn.strip() == '+'):
   out = (real_lhs + real_rhs)
  else:
   out = (real_lhs - real_rhs)
 except (ValueError, TypeError):
  return None
 return str(out)

def _sqlite_format_dtdelta ( conn , lhs , rhs ) : try : if isinstance ( lhs , int ) : lhs = str ( ( decimal . Decimal ( lhs ) / decimal . Decimal ( 1000000 ) ) ) real_lhs = parse_duration ( lhs ) if ( real_lhs is None ) : real_lhs = backend_utils . typecast_timestamp ( lhs ) if isinstance ( rhs , int ) : rhs = str ( ( decimal . Decimal ( rhs ) / decimal . Decimal ( 1000000 ) ) ) real_rhs = parse_duration ( rhs ) if ( real_rhs is None ) : real_rhs = backend_utils . typecast_timestamp ( rhs ) if ( conn . strip ( ) == '+' ) : out = ( real_lhs + real_rhs ) else : out = ( real_lhs - real_rhs ) except ( ValueError , TypeError ) : return None return str ( out )
lhs and rhs can be either: - an integer number of microseconds - a string representing a timedelta object - a string representing a datetime .