function [ w, f ] = jed_to_weekday ( jed )

%*****************************************************************************80
%
%% JED_TO_WEEKDAY computes the day of the week from a JED.
%
%  Discussion:
%
%    BC 4713/01/01 => JED = 0.0 was noon on a Monday.
%
%    [-0.5,+0.5] -> MONDAY.
%
%    jedmod = mod ( 0.0+0.5, 7.0 ) = 0.0
%    j = mod ( nint ( 0 ), 7 ) = 0
%    f = ( 0.0 + 0.5 ) - real ( j ) = 0.5
%    w = i4_wrap ( 0 + 2, 1, 7 ) = 2 = MONDAY
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    04 July 2017
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Edward Richards,
%    Mapping Time, The Calendar and Its History,
%    Oxford, 1999.
%
%  Parameters:
%
%    Input, real JED, the Julian Ephemeris Date.
%
%    Output, integer W, the day of the week of the date.
%    The days are numbered from Sunday through Saturday, 1 through 7.
%
%    Output, real F, the fractional part of the day.
%
  jedp = jed + 0.5;

  jedpfrac = mod ( jedp, 1.0 );
  jedpwhole = jedp - jedpfrac;

  f = jedpfrac;

  w = i4_wrap ( jedpwhole + 2, 1, 7 );

  return
end
