function [ y, m, d, f ] = jed_to_ymdf_hindu_solar ( jed )

%*****************************************************************************80
%
%% jed_to_ymdf_hindu_solar() converts a JED to a Hindu solar YMDF date.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 March 2013
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Edward Reingold, Nachum Dershowitz, Stewart Clamen,
%    Calendrical Calculations, II: Three Historical Calendars,
%    Software - Practice and Experience,
%    Volume 23, Number 4, pages 383-404, April 1993.
%
%  Input:
%
%    real JED, the Julian Ephemeris Date.
%
%  Output:
%
%    integer Y, M, D, real F, the YMDF date.
%

%
%  Date = JF.
%
  jf = jed;
%
%  Date = JED_EPOCH + JF
%
  jed_epoch = epoch_to_jed_hindu_solar ( );
  jf = jf - jed_epoch;
%
%  Date = JED_EPOCH + Y years + JF
%
  yz = 0;
  y = floor ( jf / year_length_days_hindu_solar ( yz ) );
  jf = jf - floor ( y * year_length_days_hindu_solar ( yz ) );
%
%  Date = JED_EPOCH + Y years + ( M - 1 ) months + JF
%
  mz = 0;
  m = 1 + floor ( jf / month_length_hindu_solar ( yz, mz ) );
  jf = jf - floor ( ( m - 1 ) * month_length_hindu_solar ( yz, mz ) );
%
%  Date = JED_EPOCH + Y years + ( M - 1 ) months + ( D - 1 ) days + f
%
  d = floor ( jf ) + 1;
  f = jf - ( d - 1 );

  return
end

