How to predict the Islamic calendar with a high-accuracy ephemeris

Like most Muslims around the world, my daily life is measured by a combination of the Gregorian Calendar and Coordinated Universal Time (UTC) with time zones. There is only one exception: every year I fast in Ramadan, the dates of which are not standardized. All over the world, Muslim countries and Islamic institutions appoint their own arbiters for the dates of Ramadan, and the result is that:

  1. The 1st of Ramadan and Eid al-Fitr (1st of Shawwal) are unpredictable. This is inconvenient.
  2. We end up starting and finishing Ramadan on different days (spread over about 4 days). This, I feel, is a greater shame, as I would like to be able to share the fast with my family in different countries and with Muslims locally, wherever I am.

So I studied this matter, with the aim of predicting standard dates for Ramadan in the future. I leave it to the reader to choose whether to consider this as a standardization or a prediction of Ramadan. The method and results are below.

New moon: conjunction and sighting, Islamic law and conventional practice

Most Muslim scholars consider that the new month of the Islamic calendar begins with the sighting of the new moon. Astronomically, the new moon is the conjunction of the moon and the sun: in terms of astronomical coordinates, the conjunction occurs when the right ascension of the moon equals the right ascension of the sun. But the trouble with the conjunction is that it is invisible: the moon is aligned with the sun, and sets simultaneously with the sun. It only becomes visible later to the naked eye, typically 18 hours later, as a thin crescent.

Telescope image of the new moon, perhaps about a day old


As is recorded in the Hadith, “Allah’s Messenger (peace be upon him) said: Whenever you sight the new moon (of the month of Ramadan) observe the fast, and when you sight it (the new moon of Shawwal) break it, and if the sky is cloudy for you, then observe the fast for thirty days.”

This is taken by most Muslim scholars today as a basis for the opinion that one must wait for the sighting of the moon, and it is wrong to base the calendar on standards or calculations. On the other hand, there have been many standards of the Islamic calendar historically. Note that the Qur’an gives an impression which is quite different from the conventional opinion:

The sun and the moon [move] by precise calculation (Qur’an, Surat Ar-Raĥmān 55:5)


It is He who made the sun a shining light and the moon a derived light and determined for it phases – that you may know the number of years and account [of time]. Allah has not created this except in truth. He details the signs for a people who know  (Qur’an, Surat Yūnus 10:5)

This is a complicated subject fraught with disagreements, so I refer the reader to much better articles on the Islamic perspectives:

My view is that, as long as we wait for the sighting of the moon (or follow other people who claim to have sighted the moon), we will never start and finish Ramadan on the same day. Consider the following:

  1. The world is round and there are different time zones. Suppose the moon is sighted in Mecca (or further east, say in Indonesia) after sunset. However, at the same moment, in Hawaii (or North America), the sun has already risen, and Muslims have started the fast. Should they then break their fast immediately, or wait for the following sunset? Even if all Muslims around the world followed a single human authority on the moon sighting, this means that they would still break their fasts on separate days.
  2. Humans will never agree on the moon sighting, even in the same location, under clear skies, because the moon sighting depends on one’s eyesight. At the start and end of Ramadan, people compete with each other to be the first to see the new moon, with the result that 1st Ramadan and 1st Shawwal are declared while it is actually still impossible for 99% of ordinary people to see the new moon with the naked eye.

How to standardize the Islamic calendar so that all Muslims can fast on the same dates?

I recent read a proposed standardization of Islamic calendar dates, which I find to be strikingly simple, elegant and robust:

The new Islamic Lunar month begins at sunset of the day when the conjunction occurs before 12:00 Noon UTC.

This standardization was originally proposed by the Fiqh Council of North America in 2006. However, they later abandoned it because they were roundly criticized by traditionalists. So, let’s neglect their role in it, and consider it only on its own merits.

Firstly, why “12 Noon Coordinated Universal Time (UTC)”? The advantage of UTC is that it is an astronomical standard, also known as GMT. At this moment, the whole world is on the same the same day of the week and the same date in the Gregorian calendar. This would not be the case if we considered another place or point in time: sunset in Mecca is not a standard time. Sunset in Mecca varies in time of day, and at that moment of sunset, midnight has already passed in the Far East, which is then on the next day of the Gregorian calendar.

Secondly, why “conjunction before Noon”? The result of this is that somewhere on the Earth’s surface there will probably be a sighting of the moon on the same date in the Gregorian calendar. It also corresponds pretty well with the actual dates that are declared.

Hypothetically, if we consider this proposal, we can see how easy it is to predict Ramadan in the future.

Ephemeris: the motion of the heavenly bodies

Three institutions in the world publish a high-accuracy ephemeris. These are: the NASA Jet Propulsion Laboratory’s DE (Development Ephemeris) series ephemerides, the Paris Observatory (Intégrateur Numérique Planétaire de l’Observatoire de Paris, or INPOP) and the Institute of Applied Astronomy in St. Petersburg (Ephemerides Planets-Moon, or EPM). I am no expert on these models, but see here for a comparison. Of course, nobody knows the future except Allah, and we should say “inshallah” even for a high-accuracy planetary ephemeris. However, the ayats from the Qur’an quoted above, still encourage us to think of the motion of heavenly bodies as standards in time. The JPL Ephemeris is believed to predict the moon position to an accuracy within about 20 m in the coming century.

Predicting the Islamic calendar with the NASA JPL Development Ephemeris

So hypothetically, let’s see how easy it is to predict the Islamic calendar with NASA’s JPL Development Ephemeris. The JPL maintains a website (and telnet service) Horizons, which uses the latest version of their model DE430/DE431. Try the following:

  1. Visit or use telnet to, port 6775
  2. Select the following options to retrieve the positions (Right Ascension) of the Sun and Moon at 12:00 Noon UTC in astronomical coordinates.
    Ephemeris Type: OBSERVER
    Target Body: Sun [Sol] [10] and Moon [Luna] 301
    Observer Location: Geocentric [500]
    Time Span: Start=2015-06-15 12:00, Stop=2215-07-20 12:00, Step=1 d
    Table Settings: QUANTITIES=2 (RA and DEC); angle format=DEG; extra precision=YES; CSV format=YES

Horizons allows you to download the data in CSV format by FTP. (One can also use other astronomical software that employs a high-accuracy ephemeris.) Then take the difference between the RA of the moon and RA of the sun. Whenever the difference RA(moon) – RA(sun) passes through zero, the conjunction has occurred. If therefore, at 12:00 Noon UTC the difference is positive, a new moon has been born before noon, and that day can be counted as the new day of the Islamic calendar, according to the standard.

Islamic calendar prediction 2015 – 2215 using JPL DE + Matlab

Plotting the difference RA(moon) – RA(sun) at 12:00 Noon UTC each day produces the following graph. Where RA(moon) – RA(sun) is negative, the moon is waning, where RA(moon) – RA(sun) is positive, the moon is waxing. the first noon where RA(moon) – RA(sun) is positive is counted as the first day of the new Islamic month. Below is the prediction for Ramadan 1437 AH: begin on 5 June 2016 (sunset) and end on 4 July 2016 (sunset), in all time zones.

Islamic calendar Ramadan 2016


You too can predict the Islamic calendar using Matlab and the Horizons output. First download the data for the sun and moon and unzip. Then follow the instructions below.

Download JPL Horizons Sun and Moon RA and DEC every day at noon 2015-2215 (zipped CSV files)



1. Import Horizons output

Run the following Matlab code to import the Horizons data files into Matlab variables ra_sun and ra_moon:

%% import data
delimiter = ',';
startRow = 35;
endRow = 73083;
formatSpec = '%s%s%s%s%s%[^\n\r]';

filename = 'luna wld20518.16.txt';
fileID = fopen(filename,'r');
textscan(fileID, '%[^\n\r]', startRow-1, 'ReturnOnError', false);
dataArray = textscan(fileID, formatSpec, endRow-startRow+1, 'Delimiter', delimiter, 'ReturnOnError', false);
date = datetime(dataArray{1});
ra_moon = str2num(char(dataArray{4}));
dec_moon = str2num(char(dataArray{5}));

filename = 'sun wld20518.15.txt';
fileID = fopen(filename,'r');
textscan(fileID, '%[^\n\r]', startRow-1, 'ReturnOnError', false);
dataArray = textscan(fileID, formatSpec, endRow-startRow+1, 'Delimiter', delimiter, 'ReturnOnError', false);
date = datetime(dataArray{1});
ra_sun = str2num(char(dataArray{4}));
dec_sun = str2num(char(dataArray{5}));

2. Calculate relative right ascension, new moon dates and Islamic month order

ra_rel = angle(exp(1i*(ra_moon-ra_sun)/180*pi))/pi*180;

waxing = sign(double(ra_rel>=0));
moonborn = find([0;diff(waxing)]>0);
moonfull = find([0;diff(waxing)]<0);
Islamic_month_begins_at_sunset_of_Gregorian_date = date(moonborn);
ra_rel(moonfull) = NaN;
months = {'Muharram', 'Safar', 'Rabi'' I', 'Rabi'' II', 'Jumada I', 'Jumada II', 'Rajab', 'Sha''ban', 'Ramadan', 'Shawwal', 'Dhu al-Qa''dah', 'Dhu al-Hijjah'}';
newmonth = mod((1:length(Islamic_month_begins_at_sunset_of_Gregorian_date))+7,12)+1;
Islamic_month = months(newmonth);

3. Plot calendar

hold on
ylabel('RA(moon) - RA(sun)')
grid on

4. Write output table (CSV)

monthtable = table(Islamic_month_begins_at_sunset_of_Gregorian_date, Islamic_month);
writetable(monthtable, 'Islamic_months_2015-2215.csv')

Full results

Full results in my separate post.


  1. Hello, Sir. I am Uzli. I am a student from Indonesia. I interested with your new topic. I think it’s really good thinking.
    Would you like to let me know about the way to look for all month of the Islamic calendar in Matlab, Sir?
    Thank you

    1. Thanks for your question Uzli. In fact, the script above predicts all month dates, not just 1st of Ramadan and Shawwal. You can see in the output on the other page (see “Full results” above) that all 12 Islamic months are listed.

Leave a Reply

Your email address will not be published. Required fields are marked *