function [ y, j, ierror ] = yj_check_islamic ( y, j )

%*****************************************************************************80
%
%% yj_check_islamic() checks an Islamic YJ date.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    07 March 2013
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer Y, J, the YJ date.
%
%  Output:
%
%    integer Y, J, the YJ date, possibly corrected.
%
%    integer IERROR, is 0 if no serious error was found in
%    the date, and 1 otherwise.
%

%
%  Check the year.
%
  ierror = y_check_islamic ( y );

  if ( ierror ~= 0 )
    return
  end
%
%  Make sure J is not too small or too big.
%
  [ y, j ] = j_borrow_islamic ( y, j );

  [ y, j ] = j_carry_islamic ( y, j );

  return
end
