function w = weekday_julian ( y, m, d )

%*****************************************************************************80
%
%% weekday_julian() returns the weekday of a Y/M/D Julian date.
%
%  Discussion:
%
%    This function uses Zeller's congruence.
%
%    We assume that the year before 1 was -1.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 November 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer Y, M, D: the YMD date.
%
%  Output:
%
%    integer W: the week day number of the date, with
%    1 for Sunday, through 7 for Saturday.
%
  if ( m < 3 )
    m = m + 12; 
    y = y - 1;
  end

  if ( y < 1 )
    y = y + 1;
    k = floor ( ( - y ) / 28 ) + 1;
    y = y + 28 * k;
  end
 
  w = mod ( ...
     d ...
     + floor ( ( ( m + 1 ) * 13 ) / 5 ) ...
     + y ...
     + floor ( y / 4 ) + 4, ...
     7 ) + 1;
			
   return
end
