VedicDateTime

Calendar systems adopted across the world are either solar, lunar or lunisolar, based on the movements of the sun, the moon, or both. The Gregorian (solar) calendars are considered as time references for modern computations. However, Vedic calendars, being lunisolar, can be more effective for the analysis of activities that depend on both celestial bodies. In this paper, we present , an open-source framework that implements the Vedic calendar and provides conversions for Gregorian dates. Along with package details, we also provide two case studies that make use of the proposed package for time-series analysis. The objective of this paper is to motivate researchers to explore the potential of the Vedic calendar from the perspective of time series analysis.


Introduction
The whole concept of VedicDateTime is based on the Hindu calendar system.The lunisolar Hindu calendar and its aspects are as old as Surya Siddhanta, an ancient Sanskrit text on astronomy [1] .Even today, this calendar is prevalent in India and it is mostly found in Hindu Panchanga an Indian almanac that details information about the various festivals, rituals, and planetary combinations and has been in use since time immemorial in the Indian subcontinent.This Panchanga can be commonly found in most Indian homes [4].
The VedicDateTime package aims to convert the commonly used Gregorian date-time to the Vedic date-time as per the calculations of the Panchang.Panchanga which means 'five arms' consists of the five most important parts -Tithi, Vaara, Nakshatra, Yoga, and Karana.The Vaara or the day of the week is based on Sun alone; Tithi and Karana are based upon Moon alone; Nakshatra and Yoga are based upon both Moon and Sun.This makes the Hindu calendar a true lunisolar calendar.VedicDateTime contributes a new calendar system in R that can have huge potential to discover meaningful patterns in natural time series.[2] Before we get into calendar systems, we need to be clear with the concept of Ayanamsha.The Earth revolves anti-clockwise around the Sun in an elliptical orbit.The time taken by the earth to arrive at one vernal equinox from the other vernal equinox after one revolution is called as tropical year.At the end of the tropical year if we consider the position of the Earth with respect to a fixed star in the zodiac, the Earth appears to lie 50.26 seconds of celestial longitude to the west of its original position.In order to arrive at the same position with respect to a fixed star in the zodiac, the time taken is called as sidereal year.This is the result of precession of the Earth's axis due to its wobble in clockwise direction.The precession of the equinoxes increases by 50.2 seconds every year.The distance between the Vernal equinox and the 1st point of Aries (Mesha) on the fixed zodiac is progressively increasing.The distance at any given point of time is called as Ayanamsha.
We have two calendar systems-Sayana and Nirayana.Sayana calendars, also called as tropical calendars which means with Ayana.Nirayana calendars, also called as sidereal calendars which means without Ayana.The Nirayana values can be found out by subtracting the Ayanamsa from the Sayana values.
Each aspect (function) of the package is explained below.Each and every detail concerning each function is mentioned there and then.

Panchanga
Tithi "The luminosity of the Moon is caused by light from the Sun.It is the varying relative positions of the Sun and the Moon that produce the phases of the Moon."[4] Tithi can be called as a lunar day.When the moon traverses 12°in longitude relative to the sun, a tithi is completed.Fifteen tithis in the waxing phase (Shukla paksha) with end tithi as full moon day (Purnima) and other fifteen tithis in the waning phase (Krishna paksha) with end tithi as new moon day (Amavasya).These phases together constitute a lunar month which is of thirty tithis.Tithi doesn't require Ayanamsa because it is the difference of longitudes and even if Ayanamsa is subtracted from each longitude, it doesn't matter [3].At first, we take the date as Julian's day number and place as the latitude, longitude, and time zone of the place for which the calculations are to be made as parameters of the function.The sunrise for the given date and place is found using another function which uses the Swiss-ephemeris to get the sunrise as a Julian day number.Tithi is found out during the sunrise as the difference between lunar and solar longitudes divided by 12. Tithi is generally obtained as a decimal number.The fractional part of the Tithi is used to find out the remaining degrees to the next Tithi which is used to find the time when that Tithi ends.The time taken to complete the remaining degrees is given by Inverse Lagrange's interpolation of the Tithis found by using the lunar and solar longitudes at the intervals of 0.25 days from sunrise.The obtained Tithi and its ending time are added to the output vector.Sometimes two Tithis can occur on a given date so, we check for skipped tithi by checking the Tithi of the next day and if a Tithi is skipped then, the skipped Tithi is included in the output with its ending time.The timings greater than 24:00 represents the time past midnight.The ending time of that Tithi in the next day can be obtained by subtracting 24 from the hours.

Tithi's name
The Tithi number and ending date are obtained from the tithi function.The Tithi's name associated with each Tithi number is returned with its ending time by this function.
The following are 30 Tithis with their corresponding numbers -

Vaara
Vaara is the day of the week very similar to the Gregorian calendar.

"The seven days of the week have the seven Grahas from the Sun to Saturn as their lords." [4]
Calculation of Vaara vaara <-function(jd) { return(as.integer(ceiling(jd+ 1)%%7) + 1) } Vaara for a given Julian day number The above output represents 1 -Ravivara.

Vaara's name
The following are 7 Vaaras with their corresponding numbers - Get name of the Vaara for given Julian day number.get_vaara_name(2459778) #> [1] "Ravivar" get_vaara_name(gregorian_to_jd(6, 8, 2022)) #> [1] "Shaniwar" Nakshatra "Imagine a belt or a path in the sky, some 18 degrees of arc in width, running around the earth in an east-west direction.Groups of stars, to all appearance fixed, are studded along this imaginary belt.Twenty seven (or twenty eight!) such groups of stars are recognised in Vedic astrology.Because of lack of apparent motion, these are called as Nakshatras.This imaginary belt, with nakshatras studded on it, is called the zodiac.The zodiac forms the reference point for fixing up the position of any planet or star in the sky.Since it encircles the earth, it is comprised of 360 degrees.The twenty-seven nakshatras being evenly placed on it each have a span of 13°20' arc.The various nakshatras are numbered from one to twenty-seven."[4] The absolute longitude of the Moon is used to calculate the Nakshatra of the day.This requires Ayanamsa to be subtracted from the moon's tropical (Sayana) longitude to get its sidereal (Nirayana) longitude which can be used to find out the nakshatra.

nakshatra(jd,place)
Set ayanamsa to Lahiri ayanamsa in the Swiss Ephemeris The Ayanamsa which is obtained from the Swiss Ephemeris and is set to Lahiri Ayanamsa.Date as Julian's day number and the place as latitude, longitude, and time zone are passed as arguments of the function.
The sunrise for the given date and place is found using the sunrise function which uses the Swiss Ephemeris to get the sunrise as a Julian day number.The Nirayana longitude of the Moon is obtained by subtracting the Ayanamsa from its Sayana longitude.The Nirayana longitude of moon is multiplied by 27 and then divided by 360 to get Nakshatra as a decimal number.The ending time of this Nakshatra is obtained by checking for the starting time of the next Nakshatra using Lagrange's inverse interpolation of Nirayana lunar longitudes at 0.25 intervals of day.Nakshatra and its ending time are added to the output vector.Sometimes two Nakshatras can occur on a given date so, we check for skipped Nakshatra by checking the Nakshatra of the next day and if a Nakshatra is skipped then, the skipped Nakshatra is included in the output with its ending time.
Nakshatra for given date and place.
jd <-2459778 #Julian day number place <-c(15.34,75.13, +5.5) #Latitude, Longitude and timezone of the location nakshatra(jd, place) #> [1] 25 24 24 3 In the above output, the first number represents the number associated with the respective Nakshatra.25 represents Purvabhadrapada.This Nakshatra ends on the next day at 0 hours 24 minutes and 1 second which is represented by the rest of the numbers.

Nakshatra's name
The following are 27 Nakshatras with their corresponding numbers -

Yoga
There are 27 Yogas, each measure 13°20' of the arc.Yoga is the sum of sidereal (Nirayana) longitudes of sun and moon in the multiples of 13°20'.When the sidereal longitudes of sun and moon are added and they are divided by 13°20', the quotient plus one gives the number which denotes the respective Yoga.

From an Indian astrological perspective, "A yoga is a specific disposition of a planet or planets which is productive of specific results.
There are hundreds, nay thousands, of yogas described in astrological texts.Their presence or absence in a horoscope, as also their strength and placement, determines the nature and stature of a native."[4] yoga(jd,place) Set ayanamsa to Lahiri ayanamsa in the Swiss Ephemeris The Ayanamsa which is obtained from the Swiss Ephemeris and is set to Lahiri Ayanamsa.Date as Julian's day number and the place as latitude, longitude, and time zone are passed as arguments of the function.
The sunrise for the given date and place is found using the sunrise function which uses the Swiss Ephemeris to get the sunrise as a Julian day number.The Nirayana longitudes of the sun and moon are obtained by subtracting Ayanamsa from their Sayana longitudes.The sum of Nirayana longitudes of Moon and Sun is obtained and their mod 360 is performed so that the sum does not exceed 360.The resulting sum is multiplied by 27 and then divided by 360 to get Yoga as a decimal number.The fractional part of the Yoga is used to find out the remaining degrees to the next Yoga which is used to find the time when that Yoga ends.The time taken to complete the remaining degrees is given by Inverse Lagrange's interpolation of the Yoga found by using the lunar and solar longitudes at the intervals of 0.25 days from sunrise.The obtained Yoga and its ending time are added to the output vector.Sometimes two Yogas can occur on a given date so, we check for skipped Yoga by checking the Yoga of the next day and if a Yoga is skipped then, the skipped Yoga is included in the output with its ending time.
Yoga for given date and place.In the above output, the first number represents the number associated with the respective Yoga.26 represents Indra.This Yoga ends at 17 hours 17 minutes and 57 seconds which is represented by the rest of the numbers.

Yoga's name
The following are 27 Yogas with their corresponding numbers -

Karana
A Karana is half of a tithi or when the moon traverses 6°in longitude relative to the sun.In 30 tithis of a lunar month, there are 60 Karanas or half-tithis.

return(answer) }
To find out Karana for a given date and place where, date is given as a Julian day number and place as latitude, longitude and time zone.Date and place are passed to the Tithi function which finds out the Tithi(s).This Tithis are used to output corresponding Karnas.
There are 4 Karanas that occur only once in a lunar month.They are the fixed Karanas and called as: 1.Shakuni: assigned to the latter half of the 14th day of Krishna-paksha.2.Chatushpada: assigned to the first half of the Amavasya (15th day of Krishna-paksha).3.Naga: assigned to the latter half of the Amavasya.4.Kimstughna: assigned to the first half of the first day of the Shukla-paksha.
The remaining seven Karanas recur eight times during rest of the lunar month.Their names are: 1. Bava 2. Balava 3. Kanlava 4. Taitila 5. Gara 6. Vanija 7. Visht These Karanas recur in regular order starting from the second half of the first day of Shukla-paksha until the first half of the 14th day of the Krishna-paksha.[4] Karana for given date and place.The above pair of numbers represent these Karanas -"Vanija-Visti".

Karana's name
Get name(s) of the Karana for given Julian day number and place.
"When the zodiac is divided into twelve equal parts, each such part has an extension of 30 degrees of the arc.Such a division is called a Sign or Rashi.A sign consists of two and a quarter nakshatras.A particular group of stars in the zodiac is considered as the starting point of the zodiac.From this point, the twenty-seven nakshatras or the twelve signs begin.A planet located anywhere along the zodiac may be considered as located in a particular sign, depending upon which twelfth division of the zodiac it is in; it may be considered as being located in a particular nakshatra too, depending upon which twenty seventh division of the zodiac it is in."[4] Rashi (moon sign) represents the position of the moon on the zodiac at a given time.The Ayanamsa is set to Lahiri ayanamsa and the lunar longitude(tropical) is obtained for the given date which is taken as the Julian day number.The sidereal (Nirayana) longitude of the moon is calculated by subtracting the Ayanamsa from the obtained tropical longitude then a mod of 360 is performed to ensure that it doesn't exceed 360 and the result is divided by 30 to obtain Rashi as an integer.

Rashi's name
The following are Rashis with their corresponding numbers - Gives name of the Rashi(Sun-sign) for a given Julian day number jd <-gregorian_to_jd(17, 6, 2022) #Julian day number get_rashi_name(jd) #> [1] "Makara" Lagna Lagna (sun sign) represents the position of the sun on the zodiac at a given time.
From an Indian astronomical perspective, "The twelve houses of a horoscope deal with all conceivable aspects of life.The most important of all houses is the lagna or the first house.The remaining houses are basically related to the first house only.The planets in the horoscopic chart are subservient to the lagna, and their original nature undergoes modifications depending upon the lagna."[4] Calculation of Lagna lagna <-function(jd) { swe_set_sid_mode(SE$SIDM_LAHIRI, 0, 0) s = sun_longitude(jd) solar_nirayana = (sun_longitude(jd) -swe_get_ayanamsa_ex_ut(jd, SE$FLG_SWIEPH + SE$FLG_NONUT)$daya)%%360 return(ceiling(solar_nirayana/30)) } The Ayanamsa is set to Lahiri ayanamsa and the solar longitude(tropical) is obtained for the given date which is taken as the Julian day number.The sidereal (Nirayana) longitude of the sun is calculated by subtracting the Ayanamsa from the obtained tropical longitude then a mod of 360 is performed to ensure that it doesn't exceed 360 and the result is divided by 30 to obtain Lagna as an integer.
Lagna(sun-sign) for a given Julian day number -

paksha panchami. This tithi ends at 20 hours 55 minutes and 35 seconds which
is represented by the rest of the numbers.In the above output, 6 numbers are returned out of which the first 3 numbers represent the Tithi name and ending time of the first Tithi and the next 3 numbers represent the Tithi name and ending time of the second Tithi.Here, on

17th June 2022, two Tithis had occurred -18 which represents Krishna paksha trititya ending at 6hrs 11mins and 26secs and 19 which represents Krishna paksha chaturthi ending at 2hrs 59mins and 58secs on the next day 18th June 2022.
of the Tithi for given Julian day number and place.
In the above output, the first number represents the number associated with the respective Yoga. 5 represents Sobhana.This Yoga ends on the next day at 3 hours 26 minutes and 12 seconds which is represented by the rest of the numbers.
of the Yoga for given Julian day number and place.