function [ bspl2s ] = BSPL2S( i,t1 )
%BSPL2S bspl2s
%
%******************************************************************
%      function bspl2s(i,t1)
%******************************************************************

%      dimension ts(0:36),b(30,30)
%
  persistent ts;
  if isempty(ts)
    ts = [ 15,46,74,105,135,166,196,227,258,288,319,349, ...
             380,411,439,470,500,531,561,592,623,653,684,714, ...
             745,776,804,835,865,896,926,957,988,1018,1049, ...
             1079,1110];
  end
  b = zeros(30,30);
  
  t=t1;
  if(i >= 0 && t < ts(i+1))
     t=t+365.;
  end
  for j=i:i+2-1
    if(t >= ts(j+1) && t < ts(j+1+1))
       b(j,1)=1.;
    else
       b(j,1)=0.;
    end
  end

  for j=2:2
    for k=i:i+4-j
      b(k,j)=(t-ts(k+1))/(ts(k+j-1+1)-ts(k+1))*b(k,j-1);
      b(k,j)=b(k,j)+(ts(k+j+1)-t)/(ts(k+j+1)-ts(k+1+1))*b(k+1,j-1);
    end
  end

  bspl2s=b(i,2);

end

