function [data] = adjust_for_eod_rollover ( data )

% create two temp data sets corresponding to "k" and "k+1"
a = data(1:end-1);
b = data(2:end);

% difference the two and all values should be negative (i.e.
% 123456-123457=-1, 123456.8-123456.9=-.1 etc except for times
% that go "backwards" (i.e. from 604799 to 0) that should show up as a
% large positive number (i.e. 604799, though this could be 604784 for 15
% second data)
delta = a-b;

% find the index for all deltas that are large, then find the smallest
% index (i.e. the first eow rollover, as there may be more than one)
eow_index = min(find(delta>86380));

% if the eow_index is more than one (i.e. a rollover has been detected)
% then add 604800 to all indices after the eow rollover.  redo the a, b and
% delta values and recompute the eow_index looking for another eow
% rollover.
if( (eow_index>1) )
    data(eow_index+1:end) = data(eow_index+1:end) + 86400;
a = data(1:end-1);
b = data(2:end);
delta = a-b;
eow_index = min(find(delta<0));
end

return;