 
     -- Having calculated the right day of the month, we now apply that back to in_time
     -- which contains the otherwise-unobtainable timezone detail (and the time)
-    our_answer = our_answer - (dd::text || ''days'')::interval;
-    dd := extract( ''day'' from our_answer) - extract( ''day'' from in_time);
-    our_answer := in_time + (dd::text || ''days'')::interval;
+    our_answer = our_answer - (dd::text || 'days')::interval;
+    dd := extract( 'day' from our_answer) - extract( 'day' from in_time);
+    our_answer := in_time + (dd::text || 'days')::interval;
 
     IF weeks > 1 THEN
       weeks := weeks - 1;
-      our_answer := our_answer - (weeks::text || ''weeks'')::interval;
+      our_answer := our_answer - (weeks::text || 'weeks')::interval;
     END IF;
 
   ELSE
 
     -- Shift our date to the correct day of week..
-    our_dow := extract( ''dow'' from in_time);
+    our_dow := extract( 'dow' from in_time);
     our_dow := our_dow - dow;
-    dd := extract( ''day'' from in_time);
+    dd := extract( 'day' from in_time);
     IF our_dow >= dd THEN
       our_dow := our_dow - 7;
     END IF;
-    our_answer := in_time - (our_dow::text || ''days'')::interval;
-    dd = extract( ''day'' from our_answer);
+    our_answer := in_time - (our_dow::text || 'days')::interval;
+    dd = extract( 'day' from our_answer);
 
     -- Shift the date to the correct week...
     dd := weeks - ((dd+6) / 7);
     IF dd != 0 THEN
-      our_answer := our_answer + ((dd::text || ''weeks'')::interval);
+      our_answer := our_answer + ((dd::text || 'weeks')::interval);
     END IF;
 
   END IF;

      END IF;
    END LOOP;
  END LOOP;
  IF out_confers ~* ''A'' OR (out_confers ~* ''B'' AND out_confers ~* ''F'' AND out_confers ~* ''R'' AND out_confers ~* ''W'' AND out_confers ~* ''U'') THEN
    out_confers := ''A'';
  END IF;
  IF out_confers != '''' THEN
    RETURN dbg || out_confers;
  END IF;

  -- RAISE NOTICE ''No complex relationships between % and %'', in_from, in_to;

  SELECT rt1.confers INTO out_confers, tmp_confers1 FROM relationship r1 JOIN relationship_type rt1 ON ( r1.rt_id = rt1.rt_id )
              LEFT OUTER JOIN relationship r2 ON ( rt1.rt_id = r2.rt_id )

  END IF;
  RETURN TRUE;
END;
$$ LANGUAGE 'plpgsql' STRICT;

-- List a user's relationships as a text string
CREATE or REPLACE FUNCTION relationship_list( INTEGER ) RETURNS TEXT AS $$
DECLARE
  user ALIAS FOR $1;
  r RECORD;
  rlist TEXT;
BEGIN
  rlist := '';
  FOR r IN SELECT rt_name, fullname FROM relationship
                          LEFT JOIN relationship_type USING(rt_id) LEFT JOIN usr tgt ON to_user = tgt.user_no
                          WHERE from_user = user
  LOOP
    rlist := rlist
             || CASE WHEN rlist = ' THEN ' ELSE ', ' END
             || r.rt_name || '(' || r.fullname || ')';
  END LOOP;
  RETURN rlist;
END;
$$ LANGUAGE 'plpgsql';

DROP FUNCTION rename_davical_user( TEXT, TEXT );
DROP TRIGGER usr_modified ON usr CASCADE;
