function nss1993 = nosecsince1993(year,month,day,a,b,c)

% function nss1993 = nosecsince1993(year,month,day,a,b,c)
%
% compute the number of seconds since Jan. 1, 1993 0 UTC
% this is what the AIRS times are in 
% input time can be in Year, Month, Day, Hour, Minute, Second
%                   or Year, Month, Day, fractional time since 0UT
%                   or nssLastSunday (number of seconds since last Sunday)
%


if nargin == 1
  nssLastSunday = year;
  year = input('What is the year of the previous Sunday : ');
  month = input('What is the month of the previous Sunday : ');
  day = input('What is the day of the previous Sunday : ');
  nss1993 = nssLastSunday + nosecsince1993(year,month,day,0) - nosecsince1993(1993,1,1,0);
  return  
end

% Main equation:
% nss1993 = nds1993*spd + nss0ut
% #seconds since 1993 = (# days since 1993)*(seconds per day) + 
%   (# seconds since 0UT)

% nds1993

nds1993 = 0;   % total number of days since 1993

% compute # days in years leading up to current year
if year > 1993
	Y = (1993 : 1 : year - 1)';
	for i = 1:length(Y)
		if rem(Y(i),4)==0;
			nds1993 = nds1993 + 366;
		else
			nds1993 = nds1993 + 365;
		end
	end
end

% compute # days in months from 1st of year to current month
dpm = [31 28 31 30 31 30 31 31 30 31 30 31]; %days per month (non-leap yr)
if month > 1
	M = (1 : 1 : month - 1)';
	for i = 1:length(M)
		if M(i)==2 & rem(year,4)==0 % if February & leap year
			nds1993 = nds1993 + 29;
		else
			nds1993 = nds1993 + dpm(M(i));
		end
	end
end

% compute # days from 1st of month to current day
if day > 1
	D = (1 : 1 : day - 1)';
	nds1993 = nds1993 + length(D);
end

%disp([num2str(nds1993) ' days since 1993'])

% now compute # seconds since 0UT for the last day
if nargin == 6
	hour = a;
	minute = b;
	second = c;
	nss0ut = hour*60*60 + minute*60 + second;
elseif nargin == 4
	ft = a;
	nss0ut = ft*24*60*60;
end
%disp([num2str(nss0ut) ' seconds since 0UT'])

nss1993 = nds1993*24*60*60 + nss0ut;

