Stellarium  0.20.4
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions
GregorianCalendar Class Reference

Stellarium uses Julian Day numbers internally, and the conventional approach of using the Gregorian calendar for dates after 1582-10-15. More...

#include <GregorianCalendar.hpp>

Public Member Functions

 GregorianCalendar (double jd)
 
virtual void setJD (double JD) Q_DECL_OVERRIDE
 Set a calendar date from the Julian day number.
 
virtual void setDate (QVector< int > parts) Q_DECL_OVERRIDE
 set date from a vector of calendar date elements sorted from the largest to the smallest. More...
 
virtual QStringList getDateStrings () const Q_DECL_OVERRIDE
 get a stringlist of calendar date elements sorted from the largest to the smallest. More...
 
virtual QString getFormattedDateString () const Q_DECL_OVERRIDE
 get a formatted complete string for a date
 
- Public Member Functions inherited from JulianCalendar
 JulianCalendar (double jd)
 
virtual void retranslate () Q_DECL_OVERRIDE
 Translate e.g. stringlists of part names.
 
- Public Member Functions inherited from Calendar
 Calendar (double jd)
 
virtual double getJD () const
 Get Julian day number from a calendar date.
 
virtual QVector< int > getDate () const
 get a vector of calendar date elements sorted from the largest to the smallest. More...
 
int rdCorrSum (QVector< int >factors, int corr)
 

Static Public Member Functions

static bool isLeap (int year)
 returns true for leap years
 
static int fixedFromGregorian (QVector< int > gregorian)
 RD of January 1, AD1. More...
 
- Static Public Member Functions inherited from JulianCalendar
static QString weekday (double jd)
 return name of week day. This is actually independent from any calendar, just a modulo of JD.
 
static bool isLeap (int year)
 returns true for leap years
 
static int fixedFromJulian (QVector< int > julian)
 find RD number for date in the Julian calendar (may be used in other calendars!)
 
static QVector< int > julianFromFixed (int rd)
 find date in the Julian calendar from RD number (may be used in other calendars!)
 
- Static Public Member Functions inherited from Calendar
static double momentFromJD (double jd, bool respectUTCoffset=true)
 Interfacing function from Reingold/Dershowitz: Calendrical Calculations Returns a "moment" in RD that represents JD. More...
 
static int fixedFromMoment (double rd)
 
static double timeFromMoment (double rd)
 
static int fixedFromJD (double jd, bool respectUTCoffset=true)
 Interfacing function from Reingold/Dershowitz: Calendrical Calculations Returns a fixed date in RD that represents noon of JD. More...
 
static double momentFromMJD (double mjd)
 
static double jdFromMoment (double rd, bool respectUTCoffset=true)
 interfacing function from Reingold/Dershowitz: Calendrical Calculations Returns a JD from an RD "moment" (including fractions of day) Stellarium extension: optionally includes local time zone offset. More...
 
static double jdFromFixed (double rd, bool respectUTCoffset=true)
 interfacing function from Reingold/Dershowitz: Calendrical Calculations Returns a JD from an RD "moment" (including fractions of day) Stellarium extension: optionally includes local time zone offset. More...
 
static double mjdFromFixed (double rd)
 
static int dayOfWeekFromFixed (int rd)
 weekday from RD date. CC.UE(1.60).
 
static int kdayOnOrBefore (const Calendar::Day k, const int rd)
 the R.D. of the nearest weekday k on or before rd
 
static int kdayOnOrAfter (const Calendar::Day k, const int rd)
 the R.D. of the nearest weekday k on or after rd
 
static int kdayNearest (const Calendar::Day k, const int rd)
 the R.D. of the nearest weekday k around rd
 
static int kdayBefore (const Calendar::Day k, const int rd)
 the R.D. of the nearest weekday k before rd
 
static int kdayAfter (const Calendar::Day k, const int rd)
 the R.D. of the nearest weekday k after rd
 
static double modInterval (double x, double a, double b)
 Interval modulus, CC.UE 1.24. More...
 
static int modInterval (int x, int a, int b)
 Interval modulus, CC.UE 1.24: This EXCLUDES the upper limit! Use StelUtils::amod(x, b) for CC's (x)mod[1..b].
 
static int rdCorrSum (QVector< int >parts, QVector< int >factors, int corr)
 Reingold-Dershowitz CC.UE 1.48.
 
static QVector< int > toRadix (int num, QVector< int >radix)
 Split integer to mixed-radix vector. Reingold-Dershowitz CC.UE 1.42.
 

Static Public Attributes

static constexpr const int gregorianEpoch =1
 
- Static Public Attributes inherited from JulianCalendar
static constexpr const int julianEpoch =-1
 
- Static Public Attributes inherited from Calendar
static constexpr const double J2000 =2451545.0
 
static constexpr const double jdEpoch =-1721424.5
 
static constexpr const double mjdEpoch =678576.0
 
static constexpr const int bogus =-1000000
 

Static Protected Member Functions

static int gregorianNewYear (int year)
 
static int gregorianYearFromFixed (int rd)
 
static QVector< int > gregorianFromFixed (int rd)
 return year-month-day for RD date
 
static int nthKday (const int n, const Calendar::Day k, const int gYear, const int gMonth, const int gDay)
 

Additional Inherited Members

- Public Types inherited from JulianCalendar
enum  month {
  january =1, february, march, april,
  may, june, july, august,
  september, october, november, december
}
 
- Public Types inherited from Calendar
enum  Day {
  sunday = 0, monday, tuesday, wednesday,
  thursday, friday, saturday
}
 enum from CC.UE-ch1.12.
 
enum  Season { spring = 0, summer = 90, autumn = 180, winter = 270 }
 
- Signals inherited from Calendar
void partsChanged (QVector< int > parts)
 
void jdChanged (double jd)
 
- Protected Attributes inherited from Calendar
double JD
 
QVector< int > parts
 date expressed as JD(UT), including day fraction (ready to interact with the main application)
 
- Static Protected Attributes inherited from JulianCalendar
static QMap< int, QString > weekDayNames
 RD of January 1, AD1.
 
static QMap< int, QString > monthNames
 

Detailed Description

For dates before that, the Julian calendar is used, in the form finalized by Augustus and running unchanged since 8AD. Some European countries, especially the Protestant countries, delayed the calendar switch well into the 18th century. This implementation strictly follows CC. It provides the "Proleptic Gregorian Calendar" for dates before 1582-10-15. This may be helpful for a better estimate of seasons' beginnings in prehistory. However, also the Gregorian calendar is not perfect, and Neolithic and even earlier dates will still show deviations from the dates well-known from today.

Member Function Documentation

◆ fixedFromGregorian()

static int GregorianCalendar::fixedFromGregorian ( QVector< int >  gregorian)
static

auxiliary functions from CC.UE ch2.5 Return R.D. of date in the Gregorian calendar.

◆ getDateStrings()

virtual QStringList GregorianCalendar::getDateStrings ( ) const
virtual

Year, Month, MonthName, Day, DayName

Reimplemented from JulianCalendar.

◆ nthKday()

static int GregorianCalendar::nthKday ( const int  n,
const Calendar::Day  k,
const int  gYear,
const int  gMonth,
const int  gDay 
)
staticprotected
Returns
RD date of the n-th k-day

◆ setDate()

virtual void GregorianCalendar::setDate ( QVector< int >  parts)
virtual

Year-Month[1...12]-Day[1...31]

Reimplemented from JulianCalendar.

Reimplemented in ISOCalendar.