Stellarium  0.20.4
Public Types | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes
Calendar Class Referenceabstract

Abstract superclass for all calendars. More...

#include <Calendar.hpp>

Public Types

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

void partsChanged (QVector< int > parts)
 
void jdChanged (double jd)
 

Public Member Functions

 Calendar (double jd)
 
virtual void retranslate ()=0
 Translate e.g. stringlists of part names.
 
virtual void setJD (double JD)=0
 Set a calendar date from the Julian day number Subclasses set JD and compute the parts and possibly other data This triggers the partsChanged() signal.
 
virtual double getJD () const
 Get Julian day number from a calendar date.
 
virtual void setDate (QVector< int > parts)=0
 set date from a vector of calendar date elements sorted from the largest to the smallest. More...
 
virtual QVector< int > getDate () const
 get a vector of calendar date elements sorted from the largest to the smallest. More...
 
virtual QStringList getDateStrings () const =0
 get a stringlist of calendar date elements sorted from the largest to the smallest. More...
 
virtual QString getFormattedDateString () const
 get a formatted complete string for a date. The default implementation just concatenates all strings from getDateStrings() with a space in between.
 
int rdCorrSum (QVector< int >factors, int corr)
 

Static Public Member Functions

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 double J2000 =2451545.0
 
static constexpr const double jdEpoch =-1721424.5
 
static constexpr const double mjdEpoch =678576.0
 
static constexpr const int bogus =-1000000
 

Protected Attributes

double JD
 
QVector< int > parts
 date expressed as JD(UT), including day fraction (ready to interact with the main application)
 

Detailed Description

Stellarium uses Julian Day numbers internally, and the conventional approach of using the Gregorian calendar for dates after 1582-10-15. For dates before that, the Julian calendar is used, in the form finalized by Augustus and running unchanged since 8AD. Astronomical year counting implies having a year 0, while some calendars adhere to historical counting like 1 B.C., 1 A.D. Some European countries, especially the Protestant countries, delayed the calendar switch well into the 18th century. Other cultures have various other calendar schemes. All calendars have a numerical vector of time elements and may have individual string lists for names of elements like "week days" and "months". If the pattern of weeks and months does not apply, the names may refer to other structural elements.

The most important source used here is: Edward M. Reingold, Nachum Dershowitz: Calendrical Calculations in various editions (1997-2018), referred to as CC. In particular CC.ME=2nd "Millennium edition", CC.UE=4th "Ultimate Edition" It describes the Gregorian calendar with year zero, and the Julian without. In this plugin only, we adhere to this convention to finally have all possible variations of dates. It does not use JD directly but a number called Rata Die (RD=JD-1721424.5), a day count starting at midnight of January 1st, 1 AD (Proleptic Gregorian). with functions including "fixed" in their names. Our calendar subclasses can use Calendar::fixedFromJD(jd) / Calendar::jdFromFixed(rd).

Member Function Documentation

◆ fixedFromJD()

static int Calendar::fixedFromJD ( double  jd,
bool  respectUTCoffset = true 
)
inlinestatic

Stellarium extension: optionally includes local time zone offset. In most calendar interfacing functions, respectUTCoffset should be true.

◆ getDate()

virtual QVector<int> Calendar::getDate ( ) const
inlinevirtual

The order depends on the actual calendar

◆ getDateStrings()

virtual QStringList Calendar::getDateStrings ( ) const
pure virtual

◆ jdFromFixed()

static double Calendar::jdFromFixed ( double  rd,
bool  respectUTCoffset = true 
)
inlinestatic

In most calendar interfacing functions, respectUTCoffset should be true.

◆ jdFromMoment()

static double Calendar::jdFromMoment ( double  rd,
bool  respectUTCoffset = true 
)
static

In most calendar interfacing functions, respectUTCoffset should be true.

◆ modInterval()

static double Calendar::modInterval ( double  x,
double  a,
double  b 
)
static
Returns
x shifted to lie inside [a...b), EXCLUDING b.

◆ momentFromJD()

static double Calendar::momentFromJD ( double  jd,
bool  respectUTCoffset = true 
)
static

Stellarium extension: optionally includes local time zone offset. In most calendar interfacing functions, respectUTCoffset should be true.

◆ setDate()

virtual void Calendar::setDate ( QVector< int >  parts)
pure virtual

This triggers the jdChanged() signal Note that this must not change the time of day! You must retrieve the time from the current JD before recomputing a new JD.

Implemented in BalinesePawukonCalendar, JulianCalendar, AztecXihuitlCalendar, GregorianCalendar, RomanCalendar, ZoroastrianCalendar, AztecTonalpohualliCalendar, IcelandicCalendar, MayaHaabCalendar, MayaTzolkinCalendar, OlympicCalendar, ArmenianCalendar, CopticCalendar, EgyptianCalendar, EthiopicCalendar, MayaLongCountCalendar, and ISOCalendar.