%% QDC interpolation for period of time
% from start date to end date
%%
function qdc_db_interp (start_dt,end_dt)

%---------------------------------------------------------------------
% The function interpolates QDC between start date (start_dt)
% and end date (end_dt) - date time vectors [YYYY,MM,DD]
% and write the results to 'qdc_e', 'qdc_h' columns of the DB
% // function takes the data from pos = 'e','h','ss_e','ss_h'
%---------------------------------------------------------------------

% check time does not exceed 1 year period
d_start = datenum([start_dt,00,00,00]);
d_end = datenum([end_dt,00,00,00]);
 n = d_end - d_start;
    if n>366
        disp ('length more then 1 year !!!');
        return;
    end  %if 

%=========
% STEP 1 =
%=========
% Calculate QDC for Actual Days for certain period
% 5-days step
% E end H components are includet to the function qday_db 
% for dn = d_start:10:d_end-30 % -30 days because func qday_db takes day day+30 array
%    disp(datestr(dn,'dd-mm-yyyy'));
%    [y, m, d] = datevec(dn);
%    qday_db([y, m, d]);
%    
% end % for dn
%=========
% STEP 2 =
%=========
% Interpolate every day QDC for certain period

% Read qdc_e and qdc_h from the DB 
    qdc_x = dbget ( [start_dt,00,00,00],[end_dt,23,59,0],'qdc_x');
    qdc_y = dbget ( [start_dt,00,00,00],[end_dt,23,59,0],'qdc_y');
    
    % QDC interpolation for every day
     sqdc_x = qdc_interp (qdc_x);
     sqdc_y = qdc_interp (qdc_y);
     
 % Write every day QDC to DB
    dbset ( start_dt,[end_dt,23,59,0],'qdc_x',sqdc_x); 
    dbset ( start_dt,[end_dt,23,59,0],'qdc_y',sqdc_y); 
  
