## Research Sources

- Calendrical Calculations: Third Edition - Nachum Dershowitz and Edward M. Reingold
- Notes and Errata on Calendrical Calculations: Third Edition - 25th May 2011
- Astronomical Algorithms: First Edition - Jean Meeus
- Practical Astronomy with your Calculator: Third Edition - Peter Duffet-Smith
- How to compute planetary positions - Paul Schlyter
- Indian Calendars - Leow Choon Lian/Professor Helmer Aslaken

## Astro Library

Most of the astronomical functions have already been described in the implementation of previous astronomical Calendars. A few functions were appended to the Astro Library to implement the Hindu calendar, namely:

### astrosolar.h

#### double precession(double time)

Calculates the precession value.

#### double bisectionSearch(double a, double b, bool c, bool d)

Returns the result of bisection search between the two values *a* and *b* depending upon the conditions *c* and *d*.

#### double solarLongitudeAtOrAfter(double longitude, double time)

Computes the solar longitude at or after a given moment of time.

## KCalendarSystem API

To implement the Chinese calendar, certain changes had to be made in the KCalendar System API in order to incorporate features requiring leap months, namely:

### QString monthName(double month, int year, MonthNameFormat format = LongName)

Gets specific calendar type month for a given date. The monthName() method is overloaded to use a double type value of the month returned by calculations.

### bool julianDayToDate(int jd, int &year, double &month, double &day) const

Method to convert Julian day to calendar specific date.

### bool dateToJulianDay(int year, double month, double day, int &jd) const

Method to convert calendar specific date to Julian day.

### int daysInMonth(int year, double month) const

Returns the number of days in the given month of year. The double data type implements functionalities for leap months.

## The Hindu Calendar

The header file defining the implementation of Hindu Lunisolar Calendar is kcalendarsystemhindu.h. It has defined two classes:

### KCalendarSystemHindu

Class definition in the public domain, publicly inherited from KCalendarSystem. It re-implements the virtual functions defined in the KCalendarSystem class. The re-implemented functions are defined in the public domain of the class.

#### virtual QString calendarType() const

Returns the calendar system type.

#### virtual QDate epoch() const

Returns a QDate holding the epoch of the calendar system. Hindu epoch is defined on Julian Day 599466. (Kali Yug - January 23, -3101 in Gregorian Calendar).

#### virtual QDate earliestValidDate() const

Returns the earliest date valid in this calendar system implementation, i.e. epoch + 3044*The length of mean sidereal year, as this marks the beginning of the Vikrama Era

#### virtual QDate latestValidDate() const

Returns the latest date valid in this calendar system implementation, i.e. 9999*The length of mean sidereal year - 1

#### virtual bool isValid(int year, int month, int day) const

Returns whether a given date is valid in this calendar system.

#### virtual bool isValid(const QDate &date) const

Returns whether a given date is valid in this calendar system.

#### virtual bool isLeapYear(int year) const

Returns whether a given year is a leap year.

#### virtual bool isLeapYear(const QDate &date) const

Returns whether a given year(taken from the QDate) is a leap year.

#### virtual QString monthName(double month, int year, MonthNameFormat format = LongName) const

Gets specific calendar type month name for a given month number If an invalid month is specified, QString() is returned. The double data type is used to incorporate functionalities requiring leap months.

#### virtual QString monthName(const QDate &date, MonthNameFormat format = LongName) const

Gets specific calendar type month name for a given date.

#### virtual QString weekDayName(int weekDay, WeekDayNameFormat format = LongDayName) const

Gets specific calendar type week day name. If an invalid week day is specified, QString() is returned.

#### virtual QString weekDayName(const QDate &date, WeekDayNameFormat format = LongDayName) const

Gets specific calendar type week day name.

#### virtual int weekDayOfPray() const

Returns the weekday of pray for this calendar system, 7th day of the Hindu Week.

#### virtual bool isLunar() const

Returns whether the calendar is lunar. (False)

#### virtual bool isLunisolar() const

Returns whether the calendar is lunisolar. (True)

#### virtual bool isSolar() const

Returns whether the calendar is solar. (False)

#### virtual bool isProleptic() const

Returns whether the calendar is proleptic, i.e, supports dates before the epoch. (False)

### KCalendarSystemHinduPrivate

Class definition in the private domain, publicy inherited from KCalendarSystemPrivate. It re-implements the virtual functions defined in the KCalendarSystem class. The re-implemented functions are defined in the public domain of the class.

#### virtual void loadDefaultEraList()

Gives the Era name of the Hindu Calendar, i.e. the Vikrama Era

#### virtual KLocale::CalendarSystem calendarSystem() const

Returns the calendar type.

#### virtual int monthsInYear(int year) const

Returns the number of months in the year used by this calendar system.

#### virtual int daysInMonth(int year, int month) const

Returns the number of days in a month used by this calendar system.

#### virtual int daysInYear(int year) const

Returns the number of days in a year used by this calendar system.

#### virtual int daysInWeek() const

Returns the number of days in a week used by this calendar system, i.e, 7.

#### virtual bool isLeapYear(int year) const

Checks whether a year is a leap year or not.

#### virtual bool hasLeapMonths() const

Returns true is this calendar system has leap months. The Hindu calendar has leap months.

#### virtual bool hasYearZero() const

Returns true is this calendar system uses year 0. The Hindu calendar doesn't have a year 0.

#### virtual int maxDaysInWeek() const

Returns the maximum number of days in a week in this calendar system, i.e, 7.

#### virtual int maxMonthsInYear() const

Returns the maximum number of months in a year in this calendar system, i.e. 13.

#### virtual int earliestValidYear() const

Returns the earliest valid year in this calendar system, i.e., year 1.

#### virtual int latestValidYear() const

Returns the latest valid year in this calendar system, i.e., year 9999.

#### virtual QString monthName(double month, int year, Locale::DateTimeComponentFormat format, bool possessive) const

Gets specific calendar type month name for a given month number If an invalid month is specified, QString() is returned.

#### virtual QString weekDayName(int weekDay, KLocale::DateTimeComponentFormat format) const

Gets specific calendar type weekday name for a given month number If an invalid weekday is specified, QString() is returned.

#### double meshaSankranti(int year)

Computes the solar longitude at or after Mesha Sankranti.

#### double siderealSolarLongitude(double time)

Computes the sidereal solar longitude.

#### int siderealZodiac(double time)

Returns sidereal zodiac based on sidereal solar longitude.

#### int hinduSunrise(int date)

Returns the time of dawn at the Hindu locale.

#### int hinduCalendarYear(double time)

Returns the Hindu calendar year at the given time.

#### void julianDayToHinduDate(int jd, int &year, double &month, bool &leapMonth, double &day, bool &leapDay)

Function used to convert Julian day to Hindu date.

#### void hinduDateToJulianDay(int year, double month, bool leapMonth, double day, bool leapDay, int &jd)

Function used to convert Hindu date to Julian day.

### Astronomical Implementation

Re-implementations of the functions dateToJulianDay() and julianDayToDate() using the functions defined in the Astro Library.

#### bool julianDayToDate(int jd, int &year, double &month, double &day) const

Returns the date implemented in this calendar system from Julian day. It implements the previously defined *julianDayToHinduDate()* function.

#### bool dateToJulianDay(int &jd, int year, double month, double day) const

Returns the Julian day from the date in this calendar system. It implements the previously defined *hinduDateToJulianDay()* function.

The calculations for implementing the Hindu Calendar have been derived from the public domain Lisp code/Mathematical functions of *Calendrical Calculations* by Edward M. Reingold on the Illinois Institute of Technology website, and from the book *Astronomical Algorithms* by Jean Meeus

## No comments:

## Post a Comment