<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dr. R.P. Sharma</title>
    <description>The latest articles on DEV Community by Dr. R.P. Sharma (@drrpsharma1979).</description>
    <link>https://dev.to/drrpsharma1979</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4264900%2F71c28154-b933-4a5b-8d4a-68211bf8d35e.jpg</url>
      <title>DEV Community: Dr. R.P. Sharma</title>
      <link>https://dev.to/drrpsharma1979</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drrpsharma1979"/>
    <language>en</language>
    <item>
      <title>How I compute Hindu festival dates from Sun and Moon positions (open 2027 dataset)</title>
      <dc:creator>Dr. R.P. Sharma</dc:creator>
      <pubDate>Wed, 25 Nov 2026 14:09:16 +0000</pubDate>
      <link>https://dev.to/drrpsharma1979/how-i-compute-hindu-festival-dates-from-sun-and-moon-positions-open-2027-dataset-24ep</link>
      <guid>https://dev.to/drrpsharma1979/how-i-compute-hindu-festival-dates-from-sun-and-moon-positions-open-2027-dataset-24ep</guid>
      <description>&lt;p&gt;I have practised Vedic astrology since 1979. For most of those years, festival dates came from printed panchangs, and families often argued over which date was right when two almanacs disagreed. Today the same rules can be computed directly from planetary positions, so I published the 2027 dates as an open dataset that anyone can check or reuse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dataset (CC BY 4.0, JSON and CSV):&lt;/strong&gt; &lt;a href="https://github.com/astrologerrps-source/hindu-festival-dates-2027" rel="noopener noreferrer"&gt;https://github.com/astrologerrps-source/hindu-festival-dates-2027&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the dates move every year
&lt;/h2&gt;

&lt;p&gt;Hindu festivals follow the lunar calendar. Each one is tied to a &lt;strong&gt;tithi&lt;/strong&gt;, a lunar day. A tithi is the time the Moon takes to gain 12° on the Sun, so it runs anywhere from about 19 to 26 hours. It almost never starts at midnight, and it does not line up with civil days.&lt;/p&gt;

&lt;p&gt;So "Diwali falls on Kartika Amavasya" is not enough on its own. You also need a rule for which civil day &lt;em&gt;owns&lt;/em&gt; that tithi. Those rules are classical, and they differ from festival to festival.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rules in the dataset
&lt;/h2&gt;

&lt;p&gt;Every row has a &lt;code&gt;rule&lt;/code&gt; field that says which test fixed the date:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;udaya&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The tithi is running at sunrise&lt;/td&gt;
&lt;td&gt;Raksha Bandhan, Dussehra&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;noon&lt;/code&gt; / &lt;code&gt;madhyahna-overlap&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The tithi covers midday&lt;/td&gt;
&lt;td&gt;Ram Navami, Ganesh Chaturthi&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sunset&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The tithi is running at sunset (pradosh)&lt;/td&gt;
&lt;td&gt;Diwali, Karwa Chauth, Holika Dahan&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;midnight&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The tithi covers midnight (nishita)&lt;/td&gt;
&lt;td&gt;Janmashtami, Maha Shivratri&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;sankranti&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The Sun enters a sidereal sign&lt;/td&gt;
&lt;td&gt;Baisakhi, Vishwakarma Puja&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;aparahna (shradh)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The tithi covers the afternoon&lt;/td&gt;
&lt;td&gt;Sarva Pitru Amavasya&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This is why Holi and Diwali can shift by a day from one source to another: a sunrise rule and a sunset rule give different answers when a tithi starts in the afternoon.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the positions are computed
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Sun and Moon longitudes come from &lt;strong&gt;Swiss Ephemeris&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Positions are sidereal, using the &lt;strong&gt;Lahiri ayanamsa&lt;/strong&gt;, the standard in Indian almanacs.&lt;/li&gt;
&lt;li&gt;Sunrise and sunset are computed for the reference location in India, in IST.&lt;/li&gt;
&lt;li&gt;The tithi number is &lt;code&gt;floor((moon_lon - sun_lon) mod 360 / 12) + 1&lt;/code&gt;, and I search for its start and end instants by bisection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A simplified version of the core step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;swisseph&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;swe&lt;/span&gt;

&lt;span class="n"&gt;swe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_sid_mode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;swe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SIDM_LAHIRI&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;tithi_at&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jd_ut&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;swe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;FLG_SIDEREAL&lt;/span&gt;
    &lt;span class="n"&gt;sun&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;swe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;calc_ut&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jd_ut&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;swe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SUN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;moon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;swe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;calc_ut&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;jd_ut&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;swe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MOON&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;moon&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;sun&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;  &lt;span class="c1"&gt;# 1..30&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you have tithi start and end times, each festival is a small test: is tithi N running at sunrise, at midday, at sunset or at midnight on this civil day?&lt;/p&gt;

&lt;h2&gt;
  
  
  Caveat for people outside India
&lt;/h2&gt;

&lt;p&gt;A tithi begins at one instant worldwide, but sunrise does not. A family in Toronto or London can correctly observe a festival on a different date from India. The dataset is for India (IST). For other cities, use a panchang computed for that city.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Raw data: &lt;a href="https://github.com/astrologerrps-source/hindu-festival-dates-2027/blob/main/festivals-2027.json" rel="noopener noreferrer"&gt;JSON&lt;/a&gt; and &lt;a href="https://github.com/astrologerrps-source/hindu-festival-dates-2027/blob/main/festivals-2027.csv" rel="noopener noreferrer"&gt;CSV&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Each row links to a page with the full tithi window and muhurat timings.&lt;/li&gt;
&lt;li&gt;Full calendar with explanations: &lt;a href="https://drrpsharma.com/guides/festivals-2027.html" rel="noopener noreferrer"&gt;Hindu festival calendar 2027&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Free calculators built on the same engine: &lt;a href="https://drrpsharma.com/tools/" rel="noopener noreferrer"&gt;Vedic astrology tools&lt;/a&gt; (kundli, kundli matching, daily panchang by city)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Credit "Dr. R.P. Sharma, drrpsharma.com" if you use the data. Corrections and questions are welcome in the GitHub issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  More free calculators built on the same engine
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://drrpsharma.com/tools/panchang.html" rel="noopener noreferrer"&gt;Panchang for any city&lt;/a&gt; and &lt;a href="https://drrpsharma.com/tools/tithi-today.html" rel="noopener noreferrer"&gt;today's tithi&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://drrpsharma.com/tools/rahu-kaal.html" rel="noopener noreferrer"&gt;Rahu Kaal&lt;/a&gt;, &lt;a href="https://drrpsharma.com/tools/choghadiya.html" rel="noopener noreferrer"&gt;choghadiya&lt;/a&gt; and &lt;a href="https://drrpsharma.com/tools/hora.html" rel="noopener noreferrer"&gt;hora&lt;/a&gt;, computed from local sunrise and sunset&lt;/li&gt;
&lt;li&gt;&lt;a href="https://drrpsharma.com/tools/muhurat-finder.html" rel="noopener noreferrer"&gt;Shubh muhurat 2027&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://drrpsharma.com/tools/free-kundli.html" rel="noopener noreferrer"&gt;Free kundli&lt;/a&gt; and &lt;a href="https://drrpsharma.com/tools/kundli-matching.html" rel="noopener noreferrer"&gt;kundli matching&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://drrpsharma.com/tools/embed-widget.html" rel="noopener noreferrer"&gt;Embeddable Rahu Kaal and choghadiya widget&lt;/a&gt; for community and temple websites&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;— Dr. R.P. Sharma, Vedic astrologer since 1979&lt;/p&gt;

</description>
      <category>opendata</category>
      <category>astronomy</category>
      <category>python</category>
      <category>calendar</category>
    </item>
  </channel>
</rss>
