--
-- time_interval__shift/3
--
create or replace function time_interval__shift(
  shift__interval_id integer,
  shift__start_offset_intverval interval,
  shift__end_offset_intverval interval
) returns int4 as $$

DECLARE
BEGIN
       update time_intervals
       set    start_date = start_date + shift__start_offset_intverval,
              end_date   = end_date + shift__end_offset_intverval
       where  interval_id = shift__interval_id;

       return 0;

END;
$$ language plpgsql;


--
-- time_interval__shift/3
--
create or replace function time_interval__shift(
  integer,
  integer,
  integer
) returns int4 as $$

declare 
      shift__interval_id      alias for $1;
      shift__start_offset     alias for $2; -- default 0,
      shift__end_offset       alias for $3; -- default 0
begin

      return time_interval__shift(
	         shift__interval_id,
		 to_interval(shift__start_offset,'days'),
		 to_interval(shift__end_offset,'days')
		 );

end;$$ language plpgsql;