function [x,s,shift] = lagorlead(x,s)
% LAGORLEAD  [Not a public function] Shift time series by a lag or lead.
%
% Backend IRIS function.
% No help provided.

% -IRIS Toolbox.
% -Copyright (c) 2007-2012 Jaromir Benes.

%**************************************************************************

if any(strcmp(s(1).type,'{}')) && ...
   length(s(1).subs) == 1 && ...
   length(s(1).subs{1}) == 1 && ...
   round(s(1).subs{1}) == s(1).subs{1} && ...
   ~isinf(s(1).subs{1})

   shift = s(1).subs{1};
   x.start = x.start - shift;
   s(1) = [];
else
   shift = 0;
end

end