function w = weekday_gregorian ( y, m, d )

%*****************************************************************************80
%
%% weekday_gregorian() returns the weekday of a Y/M/D Gregorian date.
%
%  Discussion:
%
%    This function uses Zeller's congruence.
%
%  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
 
  w = mod ( ...
     d ...
     + floor ( ( ( m + 1 ) * 13 ) / 5 ) ...
     + y ...
     + floor ( y / 4 ) ...
     - floor ( y / 100 ) ...
     + floor ( y / 400 ) - 1, ...
     7 ) + 1;
			
   return
end
