function [ y, j ] = j_carry_gregorian ( y, j )

%*****************************************************************************80
%
%% j_carry_gregorian() carries year-days to years in a Gregorian date.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 June 2012
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer Y, J, the YJ date.
%
%  Output:
%
%    integer Y, J, the YJ date after carrying.
%
  while ( true )

    days = year_length_days_gregorian ( y );

    if ( j < days )
      break
    end

    j = j - days;
    y = y + 1;

  end

  return
end
