CppEphem
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CEDate Class Reference

CEDate class handles conversion between different date formats. Date formats used (see CEDateType):

To set the date, use the CEDate::SetDate method.

Definition at line 43 of file CEDate.h.

Public Member Functions

 CEDate (const CEDate &other)
 Copy constructor. More...
 
 CEDate (double date=CurrentJD(), CEDateType date_format=CEDateType::JD)
 Constructor from some date format. More...
 
 CEDate (std::vector< double > date)
 Constructor from a set of Gregorian values. More...
 
int Day ()
 Get the Gregorian calendar day. More...
 
double DayFraction ()
 Get the Gregorian calendar day fraction. More...
 
double dut1 (void) const
 Return dut1 based on the date represented by this object. More...
 
double GetDate (CEDateType time_format=CEDateType::JD) const
 Return the date in a given format. More...
 
virtual double GetSecondsSinceMidnight (const double &utc_offset=0.0)
 Method for getting the number of seconds since midnight. More...
 
virtual double GetTime (const double &utc_offset=0.0) const
 Method for getting the current time. More...
 
virtual double GetTime_UTC () const
 Method for getting the current UTC time. More...
 
virtual double Gregorian () const
 Get the Gregorian calendar date formatted as a double. More...
 
virtual std::vector< double > GregorianVect ()
 Get the Gregorian calendar date formatted as a vector. More...
 
virtual double JD () const
 Get the Julian date represented by this object. More...
 
virtual double MJD () const
 Get the Modified Julian date represented by this object. More...
 
int Month ()
 Get the Gregorian calendar month. More...
 
 operator double ()
 Overload of the CEDate object which allows the object to be treated as a 'double' representing the date formatted according to 'return_type_'. More...
 
 operator double () const
 Overload of the CEDate object which allows the object to be treated as a 'double' representing the date formatted according to 'return_type_'. More...
 
CEDateoperator= (const CEDate &other)
 Copy assignent operator. More...
 
virtual void SetDate (const double &date=CurrentJD(), const CEDateType &time_format=CEDateType::JD)
 Set the date based on an actual date and the desired time_format. More...
 
virtual void SetDate (std::vector< double > date)
 Set the date based on an actual date and the desired time_format. More...
 
void SetReturnType (CEDateType return_type)
 Set the return type from the overloaded 'operator double'. More...
 
double xpolar (void) const
 Polar motion (x) for a given date. More...
 
int Year ()
 Get the Gregorian calendar year. More...
 
double ypolar (void) const
 Polar motion (y) for a given date. More...
 
virtual ~CEDate ()
 Destructor. More...
 

Static Public Member Functions

static double CurrentJD ()
 Static method for getting the current Julian date. More...
 
static double dut1 (const double &date, const CEDateType &date_type=CEDateType::JD)
 Return dut1 based on a given modified date. More...
 
static double GetMJD2JDFactor ()
 Gets the stored SOFA Julian date to Mod Julian date factor 'DJM0'. More...
 
static std::vector< double > Gregorian2GregorianVect (double gregorian)
 Helper method for converting from non-vector formatted Gregorian date to vector format Gregorian date. More...
 
static double Gregorian2JD (double gregorian)
 Gregorian calendar date -> Julian date. More...
 
static double Gregorian2MJD (double gregorian)
 Gregorian calendar formatted date -> Julian date converter. More...
 
static double GregorianVect2Gregorian (std::vector< double > gregorian)
 Helper method for converting from Gregorian vector format to the non-vector format. More...
 
static double GregorianVect2JD (std::vector< double > gregorian)
 Gregorian calendar vector formatted date -> Julian date converter. More...
 
static double GregorianVect2MJD (std::vector< double > gregorian)
 Gregorian calendar vector formatted date -> Modified Julian date converter. More...
 
static double JD2Gregorian (const double jd)
 Julian date -> Gregorian calendar date conversion method. More...
 
static std::vector< double > JD2GregorianVect (double jd)
 Julian date -> modified Julian date conversion method. More...
 
static double JD2MJD (double jd)
 Julian date -> modified Julian date conversion method. More...
 
static double MJD2Gregorian (double mjd)
 Modified Julian date -> Gregorian calendar date conversion method. More...
 
static std::vector< double > MJD2GregorianVect (double mjd)
 Modified Julian date -> Gregorian calendar, vector formatted date. More...
 
static double MJD2JD (double mjd)
 Modified Julian date -> Julian date conversion method. More...
 
static void UTC2TDB (const double &mjd, double *tdb1, double *tdb2)
 Convert the UTC MJD to TDB JD (useful for planet computations) More...
 
static void UTC2TT (const double &mjd, double *tt1, double *tt2)
 Convert the UTC MJD to TT JD. More...
 
static void UTC2UT1 (const double &mjd, double *ut11, double *ut12)
 Convert the UTC MJD to UT1 JD. More...
 
static double xpolar (const double &date, const CEDateType &date_type=CEDateType::JD)
 Polar motion (x) for a given date. More...
 
static double ypolar (const double &date, const CEDateType &date_type=CEDateType::JD)
 Polar motion (xy for a given date. More...
 

Private Member Functions

void copy_members (const CEDate &other)
 Copy data members from another date object. More...
 
void free_members (void)
 Free data members. More...
 
void init_members (void)
 Initialize the data members. More...
 

Private Attributes

double gregorian_date_
 Gregorian calendar date. Format as YYYYMMDD.DD. More...
 
std::vector< double > gregorian_date_vect_
 Vector containing the gregorian calendar date 0 - Year, 1 - Month, 2 - date, 3 - date fraction. More...
 
double julian_date_
 Julian date formated. More...
 
double mod_julian_date_
 Modified Julian date formated. More...
 
CEDateType return_type_ = CEDateType::JD
 what format the 'operator double' will return More...
 

#include <CEDate.h>

Inheritance diagram for CEDate:
Inheritance graph
[legend]

Constructor & Destructor Documentation

◆ CEDate() [1/3]

CEDate::CEDate ( double  date = CurrentJD(),
CEDateType  date_format = CEDateType::JD 
)

Constructor from some date format.

Different formats are as follows:

  • JD: Julian date
  • MJD: Modified Julian date
  • GREGORIAN: Gregorian calendar date

Definition at line 45 of file CEDate.cpp.

◆ CEDate() [2/3]

CEDate::CEDate ( std::vector< double >  date)
explicit

Constructor from a set of Gregorian values.

Parameters
[in]dateGregorian date vector of the form
  • date[0] = year
  • date[1] = month
  • date[2] = day
  • date[3] = day fraction

Definition at line 60 of file CEDate.cpp.

◆ CEDate() [3/3]

CEDate::CEDate ( const CEDate other)
explicit

Copy constructor.

Definition at line 70 of file CEDate.cpp.

◆ ~CEDate()

CEDate::~CEDate ( )
virtual

Destructor.

Definition at line 80 of file CEDate.cpp.

Member Function Documentation

◆ copy_members()

void CEDate::copy_members ( const CEDate other)
private

Copy data members from another date object.

Parameters
[in]otherCEDate object to copy from

Definition at line 686 of file CEDate.cpp.

◆ CurrentJD()

double CEDate::CurrentJD ( )
static

Static method for getting the current Julian date.

Returns
Current Julian date

Definition at line 632 of file CEDate.cpp.

◆ Day()

int CEDate::Day ( void  )
inline

Get the Gregorian calendar day.

Definition at line 210 of file CEDate.h.

◆ DayFraction()

double CEDate::DayFraction ( void  )
inline

Get the Gregorian calendar day fraction.

Definition at line 220 of file CEDate.h.

◆ dut1() [1/2]

double CEDate::dut1 ( const double &  date,
const CEDateType date_type = CEDateType::JD 
)
static

Return dut1 based on a given modified date.

Parameters
[in]dateDate object
[in]date_typeDate format of date
Returns
UT1-UTC correction (seconds) for a given date

Definition at line 447 of file CEDate.cpp.

◆ dut1() [2/2]

double CEDate::dut1 ( void  ) const

Return dut1 based on the date represented by this object.

Returns
UT1-UTC correction (seconds) for this date object

Definition at line 462 of file CEDate.cpp.

◆ free_members()

void CEDate::free_members ( void  )
private

Free data members.

Definition at line 675 of file CEDate.cpp.

◆ GetDate()

double CEDate::GetDate ( CEDateType  time_format = CEDateType::JD) const

Return the date in a given format.

Parameters
[in]time_formatFormat of the output time object (see CEDateType)

Definition at line 155 of file CEDate.cpp.

◆ GetMJD2JDFactor()

double CEDate::GetMJD2JDFactor ( void  )
inlinestatic

Gets the stored SOFA Julian date to Mod Julian date factor 'DJM0'.

Returns
conversion factor for Julian date -> Modified Julian date conversions Modified Julian date (mjd) can then be computed from this factor and the Julian date (jd) by the following:
mjd = jd - CEDate::GetMJD2JDFactor()

Definition at line 236 of file CEDate.h.

◆ GetSecondsSinceMidnight()

double CEDate::GetSecondsSinceMidnight ( const double &  utc_offset = 0.0)
virtual

Method for getting the number of seconds since midnight.

Set the 'utc_offset' in order to get local relative seconds since midnight.

Parameters
utc_offsetObserver UTC offset (dont forget about daylight saving time)
Returns
Seconds since midnight

Definition at line 591 of file CEDate.cpp.

◆ GetTime()

double CEDate::GetTime ( const double &  utc_offset = 0.0) const
virtual

Method for getting the current time.

Set the 'utc_offset' in order to get local time

Parameters
utc_offsetObserver UTC offset (dont forget about daylight saving time)
Returns
Current time formatted as HHMMSS.S

Definition at line 607 of file CEDate.cpp.

◆ GetTime_UTC()

double CEDate::GetTime_UTC ( ) const
virtual

Method for getting the current UTC time.

Returns
Current time formatted as HHMMSS.S

Definition at line 621 of file CEDate.cpp.

◆ Gregorian()

double CEDate::Gregorian ( void  ) const
inlinevirtual

Get the Gregorian calendar date formatted as a double.

Reimplemented in CERunningDate.

Definition at line 170 of file CEDate.h.

◆ Gregorian2GregorianVect()

std::vector< double > CEDate::Gregorian2GregorianVect ( double  gregorian)
static

Helper method for converting from non-vector formatted Gregorian date to vector format Gregorian date.

Parameters
[in]gregorian

Definition at line 564 of file CEDate.cpp.

◆ Gregorian2JD()

double CEDate::Gregorian2JD ( double  gregorian)
static

Gregorian calendar date -> Julian date.

Parameters
[in]gregorianGregorian calendar date formatted as YYYYMMDD.D
Returns
Julian date

Definition at line 287 of file CEDate.cpp.

◆ Gregorian2MJD()

double CEDate::Gregorian2MJD ( double  gregorian)
static

Gregorian calendar formatted date -> Julian date converter.

Parameters
[in]gregorianGregorian calendar date formatted as YYYYMMDD.D
Returns
Modified Julian Date

Definition at line 343 of file CEDate.cpp.

◆ GregorianVect()

std::vector< double > CEDate::GregorianVect ( void  )
inlinevirtual

Get the Gregorian calendar date formatted as a vector.

Definition at line 180 of file CEDate.h.

◆ GregorianVect2Gregorian()

double CEDate::GregorianVect2Gregorian ( std::vector< double >  gregorian)
static

Helper method for converting from Gregorian vector format to the non-vector format.

Parameters
[in]gregorian

Definition at line 545 of file CEDate.cpp.

◆ GregorianVect2JD()

double CEDate::GregorianVect2JD ( std::vector< double >  gregorian)
static

Gregorian calendar vector formatted date -> Julian date converter.

Calls the SOFA "iauCal2jd" function

Parameters
[in]gregorianGregorian calendar date as a 4-element vector
  • [0] = year
  • [1] = month
  • [2] = day
  • [3] = day fraction
Returns
Julian date

Definition at line 307 of file CEDate.cpp.

◆ GregorianVect2MJD()

double CEDate::GregorianVect2MJD ( std::vector< double >  gregorian)
static

Gregorian calendar vector formatted date -> Modified Julian date converter.

Parameters
[in]gregorianGregorian calendar date as a 4-element vector
  • [0] = year
  • [1] = month
  • [2] = day
  • [3] = day fraction
Returns
Modified Julian date

Definition at line 362 of file CEDate.cpp.

◆ init_members()

void CEDate::init_members ( void  )
private

Initialize the data members.

Definition at line 699 of file CEDate.cpp.

◆ JD()

double CEDate::JD ( void  ) const
inlinevirtual

Get the Julian date represented by this object.

Reimplemented in CERunningDate.

Definition at line 150 of file CEDate.h.

◆ JD2Gregorian()

double CEDate::JD2Gregorian ( const double  jd)
static

Julian date -> Gregorian calendar date conversion method.

Parameters
[in]jdJulian date
Returns
Gregorian calendar date of the form YYYYMMDD.DD

Definition at line 193 of file CEDate.cpp.

◆ JD2GregorianVect()

std::vector< double > CEDate::JD2GregorianVect ( double  jd)
static

Julian date -> modified Julian date conversion method.

This function makes use of the SOFA 'iauJd2cal' method.

Parameters
[in]jdJulian date
Returns
Gregorian calendar date as a 4-element vector
  • [0] = year
  • [1] = month
  • [2] = day
  • [3] = day fraction

Definition at line 211 of file CEDate.cpp.

◆ JD2MJD()

double CEDate::JD2MJD ( double  jd)
static

Julian date -> modified Julian date conversion method.

Parameters
[in]jdJulian date
Returns
modified Julian date

Definition at line 182 of file CEDate.cpp.

◆ MJD()

double CEDate::MJD ( void  ) const
inlinevirtual

Get the Modified Julian date represented by this object.

Reimplemented in CERunningDate.

Definition at line 160 of file CEDate.h.

◆ MJD2Gregorian()

double CEDate::MJD2Gregorian ( double  mjd)
static

Modified Julian date -> Gregorian calendar date conversion method.

Parameters
[in]mjdModified Julian date
Returns
Gregorian calendar date of the form YYYYMMDD.DD

Definition at line 253 of file CEDate.cpp.

◆ MJD2GregorianVect()

std::vector< double > CEDate::MJD2GregorianVect ( double  mjd)
static

Modified Julian date -> Gregorian calendar, vector formatted date.

Parameters
[in]mjdModified Julian date
Returns
Gregorian calendar date as a 4-element vector
  • [0] = year
  • [1] = month
  • [2] = day
  • [3] = day fraction

Definition at line 272 of file CEDate.cpp.

◆ MJD2JD()

double CEDate::MJD2JD ( double  mjd)
static

Modified Julian date -> Julian date conversion method.

Parameters
[in]mjdModified Julian date
Returns
Julian date

Definition at line 241 of file CEDate.cpp.

◆ Month()

int CEDate::Month ( void  )
inline

Get the Gregorian calendar month.

Definition at line 200 of file CEDate.h.

◆ operator double() [1/2]

CEDate::operator double ( )

Overload of the CEDate object which allows the object to be treated as a 'double' representing the date formatted according to 'return_type_'.

Definition at line 655 of file CEDate.cpp.

◆ operator double() [2/2]

CEDate::operator double ( ) const

Overload of the CEDate object which allows the object to be treated as a 'double' representing the date formatted according to 'return_type_'.

Definition at line 665 of file CEDate.cpp.

◆ operator=()

CEDate & CEDate::operator= ( const CEDate other)

Copy assignent operator.

Parameters
[in]otherCEDate object to be copied
Returns

Definition at line 90 of file CEDate.cpp.

◆ SetDate() [1/2]

void CEDate::SetDate ( const double &  date = CurrentJD(),
const CEDateType time_format = CEDateType::JD 
)
virtual

Set the date based on an actual date and the desired time_format.

Parameters
[in]dateDate
[in]time_formatTime format (see CEDateType)

Definition at line 107 of file CEDate.cpp.

◆ SetDate() [2/2]

void CEDate::SetDate ( std::vector< double >  date)
virtual

Set the date based on an actual date and the desired time_format.

Parameters
[in]dateGregorian Date
  • [0] = Year
  • [1] = Month
  • [2] = Day
  • [3] = Day fraction

Definition at line 145 of file CEDate.cpp.

◆ SetReturnType()

void CEDate::SetReturnType ( CEDateType  return_type)
inline

Set the return type from the overloaded 'operator double'.

Parameters
return_typeCEDateType for the returned double

Definition at line 247 of file CEDate.h.

◆ UTC2TDB()

void CEDate::UTC2TDB ( const double &  mjd,
double *  tdb1,
double *  tdb2 
)
static

Convert the UTC MJD to TDB JD (useful for planet computations)

Parameters
[in]mjdInput modified Julian date for computation
[out]tdb1First part of returned TDB in JD
[out]tdb2Second part of returned TDB in JD

Notes: 1) The full TDB in Julian date format can be obtained by summing tdb1 and tdb2. 2) tdb2 represents the TDB in modified Julian date 3) tdb1 should be the conversion factor between JD and MJD

Definition at line 429 of file CEDate.cpp.

◆ UTC2TT()

void CEDate::UTC2TT ( const double &  mjd,
double *  tt1,
double *  tt2 
)
static

Convert the UTC MJD to TT JD.

Parameters
[in]mjdInput modified Julian date for computation
[out]tt1First part of returned TT in JD
[out]tt2Second part of returned TT in JD

Notes: 1) The full TT in Julian date format can be obtained by summing tt1 and tt2. 2) tt2 represents the TT in modified Julian date 3) tt1 should be the conversion factor between JD and MJD

Definition at line 405 of file CEDate.cpp.

◆ UTC2UT1()

void CEDate::UTC2UT1 ( const double &  mjd,
double *  ut11,
double *  ut12 
)
static

Convert the UTC MJD to UT1 JD.

Parameters
[in]mjdInput modified Julian date for computation
[out]ut11First part of returned UT1 in JD
[out]ut12Second part of returned UT1 in JD

Notes: 1) The full ut1 in Julian date format can be obtained by summing ut11 and ut12. 2) ut12 represents the UT1 in modified Julian date 3) ut11 should be the conversion factor between JD and MJD

Definition at line 384 of file CEDate.cpp.

◆ xpolar() [1/2]

double CEDate::xpolar ( const double &  date,
const CEDateType date_type = CEDateType::JD 
)
static

Polar motion (x) for a given date.

Parameters
[in]dateDate object
[in]date_typeDate format of date
Returns
x-polar motion correction for a given date

Definition at line 494 of file CEDate.cpp.

◆ xpolar() [2/2]

double CEDate::xpolar ( void  ) const

Polar motion (x) for a given date.

Returns
x-polar motion correction for this date

Definition at line 507 of file CEDate.cpp.

◆ Year()

int CEDate::Year ( void  )
inline

Get the Gregorian calendar year.

Definition at line 190 of file CEDate.h.

◆ ypolar() [1/2]

double CEDate::ypolar ( const double &  date,
const CEDateType date_type = CEDateType::JD 
)
static

Polar motion (xy for a given date.

Parameters
[in]dateDate object
[in]date_typeDate format of date
Returns
y-polar motion correction for a given date

Definition at line 520 of file CEDate.cpp.

◆ ypolar() [2/2]

double CEDate::ypolar ( void  ) const

Polar motion (y) for a given date.

Returns
y-polar motion correction for this date

Definition at line 533 of file CEDate.cpp.

Member Data Documentation

◆ gregorian_date_

double CEDate::gregorian_date_
private

Gregorian calendar date. Format as YYYYMMDD.DD.

Definition at line 133 of file CEDate.h.

◆ gregorian_date_vect_

std::vector<double> CEDate::gregorian_date_vect_
private

Vector containing the gregorian calendar date 0 - Year, 1 - Month, 2 - date, 3 - date fraction.

Definition at line 134 of file CEDate.h.

◆ julian_date_

double CEDate::julian_date_
private

Julian date formated.

Definition at line 131 of file CEDate.h.

◆ mod_julian_date_

double CEDate::mod_julian_date_
private

Modified Julian date formated.

Definition at line 132 of file CEDate.h.

◆ return_type_

CEDateType CEDate::return_type_ = CEDateType::JD
private

what format the 'operator double' will return

Definition at line 136 of file CEDate.h.


The documentation for this class was generated from the following files: