function [ n_data, y, m, d, date_num ] = datenum_values ( n_data )

%*****************************************************************************80
%
%% datenum_values() returns the day of the week for various dates.
%
%  Discussion:
%
%    The MATLAB datenum function returns a numeric value for a given date,
%    which is 1 for the (fictitious) date 1 January 0.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    13 December 2017
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N_DATA.  The user sets N_DATA to 0 before the first call. 
%
%  Output:
%
%    integer N_DATA.  On each call, the routine increments N_DATA by 1,
%    and returns the corresponding data; when there is no more data, the
%    output value of N_DATA will be 0 again.
%
%    integer Y, M, D, the Common Era date.
%
%    integer DATE_NUM, the MATLAB datenum for the date.
%
  n_max = 11;

  d_vec = [ ...
     1, ...
     1, ...
     1, ...
     1, ...
    17, ...
     9, ...
    10, ...
    12, ...
     6, ...
    25, ...
     1];

  date_num_vec = [ ...
         1, ...
       367, ...
     36526, ...
    365244, ...
    708434, ...
    710284, ...
    713023, ...
    718199, ...
    723186, ...
    729080, ...
    730486 ];

  m_vec = [ ...
     1, ...
     1, ...
     1, ...
     1, ...
     8, ...
     9, ...
     3, ...
     5, ...
     1, ...
     2, ...
     1];

  y_vec = [ ...
        0, ...
        1, ...
      100, ...
     1000, ...
     1939, ...
     1944, ...
     1952, ...
     1966, ...
     1980, ...
     1996, ...
     2000 ];

  if ( n_data < 0 )
    n_data = 0;
  end

  n_data = n_data + 1;

  if ( n_max < n_data )
    n_data = 0;
    y = 0;
    m = 0;
    d = 0;
    date_num = 0;
  else
    y = y_vec(n_data);
    m = m_vec(n_data);
    d = d_vec(n_data);
    date_num = date_num_vec(n_data);
  end

  return
end
