Go to the documentation of this file.
133 "Invalid date type");
170 "Unrecognized time format!");
214 std::vector<double> full_gregorian_vect(4,0.0) ;
215 std::vector<int> gregorian_date(3,0.0) ;
218 if (iauJd2cal(jd, 0, &gregorian_date[0], &gregorian_date[1],
219 &gregorian_date[2], &full_gregorian_vect[3])) {
220 std::cerr <<
"[WARNING] CEDate::JD2GregorianVect() :: Bad date (" << jd <<
")!" << std::endl ;
221 return std::vector<double>(4,0.0) ;
224 full_gregorian_vect[0] = 1.0*gregorian_date[0] ;
225 full_gregorian_vect[1] = 1.0*gregorian_date[1] ;
226 full_gregorian_vect[2] = 1.0*gregorian_date[2] ;
229 return full_gregorian_vect ;
311 double mjd_factor(0.0);
315 int err_code = iauCal2jd(
int(gregorian[0]),
int(gregorian[1]),
316 int(gregorian[2]), &mjd_factor, &mjd) ;
318 std::cerr <<
"[WARNING] CEDate::GregorianVect2JD() :: Bad ";
319 if (err_code == -1) {
320 std::cerr <<
"year (" << gregorian[0] <<
"). Make sure the year is larger than -4800." << std::endl ;
322 }
else if (err_code == -2) {
323 std::cerr <<
"month (" << gregorian[1] <<
"). Make sure this number is in the range 1 -> 12." << std::endl ;
325 }
else if (err_code == -3) {
326 std::cerr <<
"day (" << gregorian[2] <<
")" << std::endl ;
334 return mjd_factor + mjd + gregorian[3] ;
437 iauTttdb(*tdb1, *tdb2, 0.0, tdb1, tdb2) ;
452 CEDate input_date(date, date_type) ;
454 return input_date.dut1() ;
498 CEDate input_date(date, date_type) ;
524 CEDate input_date(date, date_type) ;
548 int sign = (gregorian[0] < 0) ? -1.0 : 1.0;
549 double ret = std::fabs(gregorian[0]) * 10000 +
552 if (gregorian.size() == 4) {
568 std::vector<double> gregorian_vect(4,0.0) ;
569 double greg = std::fabs(gregorian);
572 gregorian_vect[3] = greg - std::floor(greg);
574 gregorian_vect[2] = int(std::floor(greg)) % 100 ;
576 gregorian_vect[1] = int(std::floor(greg - gregorian_vect[2])/100) % 100;
578 gregorian_vect[0] = int(std::floor(greg - gregorian_vect[2] - 100*gregorian_vect[1]) / 10000);
579 gregorian_vect[0] *= (gregorian < 0.0) ? -1.0 : 1.0;
581 return gregorian_vect;
594 double mjd_offset =
MJD();
595 mjd_offset -= std::floor(mjd_offset);
596 mjd_offset += utc_offset/24.0;
610 double mjd_offset =
MJD();
611 mjd_offset -= std::floor(mjd_offset);
612 mjd_offset += utc_offset/24.0;
638 struct tm current_jd;
639 gmtime_r(&now, ¤t_jd) ;
642 std::vector<double> date_info = {current_jd.tm_year+1900.0,
643 current_jd.tm_mon+1.0,
644 current_jd.tm_mday*1.0,
656 CEDate::operator double()
659 return GetDate(return_type_) ;
666 CEDate::operator double()
const
669 return GetDate(return_type_) ;
static double GregorianVect2Gregorian(std::vector< double > gregorian)
Helper method for converting from Gregorian vector format to the non-vector format.
void init_members(void)
Initialize the data members.
virtual double GetTime_UTC() const
Method for getting the current UTC time.
double gregorian_date_
Gregorian calendar date. Format as YYYYMMDD.DD.
double yp(const double &mjd)
Polar motion (x) for a given modified julian date (radians)
static double UTC(const double &jd)
Get the current UTC time.
CEDate(double date=CurrentJD(), CEDateType date_format=CEDateType::JD)
Constructor from some date format.
void copy_members(const CEDate &other)
Copy data members from another date object.
virtual double GetTime(const double &utc_offset=0.0) const
Method for getting the current time.
static std::vector< double > Gregorian2GregorianVect(double gregorian)
Helper method for converting from non-vector formatted Gregorian date to vector format Gregorian date...
double xpolar(void) const
Polar motion (x) for a given date.
static void UTC2TDB(const double &mjd, double *tdb1, double *tdb2)
Convert the UTC MJD to TDB JD (useful for planet computations)
static double Gregorian2JD(double gregorian)
Gregorian calendar date -> Julian date.
static double Gregorian2MJD(double gregorian)
Gregorian calendar formatted date -> Julian date converter.
void free_members(void)
Free data members.
double mod_julian_date_
Modified Julian date formated.
static double GregorianVect2JD(std::vector< double > gregorian)
Gregorian calendar vector formatted date -> Julian date converter.
static void UTC2UT1(const double &mjd, double *ut11, double *ut12)
Convert the UTC MJD to UT1 JD.
static std::vector< double > MJD2GregorianVect(double mjd)
Modified Julian date -> Gregorian calendar, vector formatted date.
double julian_date_
Julian date formated.
std::vector< double > gregorian_date_vect_
Vector containing the gregorian calendar date 0 - Year, 1 - Month, 2 - date, 3 - date fraction.
double ypolar(void) const
Polar motion (y) for a given date.
virtual ~CEDate()
Destructor.
static double GetMJD2JDFactor()
Gets the stored SOFA Julian date to Mod Julian date factor 'DJM0'.
static double TimeSec2Time(const double &seconds)
Convert number of seconds since midnight to HHMMSS.S formatted double.
static double CurrentUTC()
Get the current UTC time as seconds since midnight.
static double GregorianVect2MJD(std::vector< double > gregorian)
Gregorian calendar vector formatted date -> Modified Julian date converter.
static std::vector< double > JD2GregorianVect(double jd)
Julian date -> modified Julian date conversion method.
double GetDate(CEDateType time_format=CEDateType::JD) const
Return the date in a given format.
Gregorian calendar (year, month, day)
static double CurrentJD()
Static method for getting the current Julian date.
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.
static double JD2Gregorian(const double jd)
Julian date -> Gregorian calendar date conversion method.
virtual double MJD() const
Get the Modified Julian date represented by this object.
CEDate & operator=(const CEDate &other)
Copy assignent operator.
virtual double GetSecondsSinceMidnight(const double &utc_offset=0.0)
Method for getting the number of seconds since midnight.
virtual double Gregorian() const
Get the Gregorian calendar date formatted as a double.
double dut1(const double &mjd)
Return dut1 based on a given modified julian date (seconds)
double dut1(void) const
Return dut1 based on the date represented by this object.
static void UTC2TT(const double &mjd, double *tt1, double *tt2)
Convert the UTC MJD to TT JD.
virtual double JD() const
Get the Julian date represented by this object.
CEDateType return_type_
what format the 'operator double' will return
static double MJD2JD(double mjd)
Modified Julian date -> Julian date conversion method.
double ttut1(const double &mjd)
TT-UT1 correction for a given MJD (seconds)
double xp(const double &mjd)
Polar motion (x) for a given modified julian date (radians)
static double JD2MJD(double jd)
Julian date -> modified Julian date conversion method.
static double MJD2Gregorian(double mjd)
Modified Julian date -> Gregorian calendar date conversion method.