function fmd = fmodtime(flist, year_base)
%  1.  NAME
%
%  fmodtime - Get the modification time of files
%
%  2.  SYNOPSIS
%
%  mt = fmodtime(flist, year_base )
%
%  3.  DESCRIPTION
%
%  This function gets the modification time of all specified files on the
%  command line.
%
%  4.  PARAMETERS
%
%     flist
%        Array of file names with path if not in current directory.  One
%        can use strvcat on the file names to create this list.
%
%     year_base
%        Base year for decimal day conversions.
%
%  5.  RETURNS
%
%     mt Array of decimal days corresponding to the modification times
%        (relative to year_base) of each of the files in flist. If a file
%        does not exist,or is multiple,its modification time is set to
%        NaN.
%
%  6.  AUTHORS
%
%  Pierre Jaccard, Geophysical Institute, University of Bergen, 1999
%

strmonth = { 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', ...
	 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'};
nummonth = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

l = size(flist,1);
fmd = [];

% Loop through the input arguments:
for i=1:l,
  
  % Process the argument:
  f = flist(i,:);

  % Get file modification time and process it to get its value in
  % decimal days from `year_base'.
  s = dir(f);
  if length(s) == 1,
	 md = s.date;
	 % The modification time has the form: DD-MMM-YYYY hh:mm:ss
	 mi = [ 3 2 1 4 5 6 ];  % YYYY MM DD hh mm ss indexes
	 md = strsplit(md, ' -:');
	 md = cellstr(md);
	 l = strcmp(strmonth, md{2});
	 ind = find(l);
	 if length(ind) ~= 1,
		error('Cannot find the month name in file modification time.');
	 end
	 md{2} = num2str(nummonth{ind});
	 for j=1:6,
		d(j) = str2num(md{mi(j)});
	 end
	 fmd(i) = to_day(year_base, d); 
  else
	 fmd(i) = NaN;
  end
  
end

