List of all members
gnsstk::JulianDate Class Reference

Detailed Description

This class encapsulates the "Julian Date" time representation.

The implementation is in terms of "jday", which is int(JD+0.5), plus two scaled 64-bit integers (dday,fday) to represent the fraction of the day. So fraction of day = (dday+fday*JDFACT)*JDFACT where JDFACT = 1.0e-17; this yields precision up to 1e-34. Implementation of class MJD is similar.

There are a few subtle implementation issues here: (0) JD is integer at noon, which is awkward; MJD is integer at midnight. Thus the representation of "integer day" plus "fractional part of day" or similar is straightforward for MJD but for JD there is that pesky 0.5.

(1) Some compliers, notably MSVC on Windows implement long double as double. This causes a loss of precision when attempting to write JD as a single floating number (double or even long double). Therefore, point 2:

(2) Here, long double is eliminated; the long double c'tor is deprecated. There is a "long double JD()" provided, for convenience when high precision is not needed (e.g. Solar system ephemeris), but with a warning of less precision. NEVER try to store timetags for reuse as long double JD().

(3) TimeSystem is left out of the long double constructor on purpose, otherwise compilers see an ambiguity between the two c'tors (GPS here could be any system) MJD(long double jd, TimeSystem::GPS) and MJD(long ijd, double sod) because TimeSystem::GPS is an int and can be implicitly cast to double. [However note that TimeSystem(2) will not be implicitly cast.] Use setTimeSystem(TimeSystem::GPS).

(4) On constructors for JulianDate jd. The following give the same value: jd.fromString("1350000"); // full JD jd = JulianDate(1350000,43200,0.0); // jday not int(JD), sod, fsod jd.fromIntFrac(135000,0.0); // int(JD) and frac(JD)

(5) fromString() and asString() provide I/O which is repeatable and the most precise, with up to 34 decimal digits (prec ~ 1e-34 = JDFACT^2). fromIntFrac() is the worst b/c of the double fraction of the day.

Definition at line 89 of file JulianDate.hpp.

#include <JulianDate.hpp>

Inheritance diagram for gnsstk::JulianDate:
Inheritance graph
[legend]

Public Member Functions

JulianDate Basic Operations
 JulianDate (long double j=0., TimeSystem ts=TimeSystem::Unknown)
 
 JulianDate (const JulianDate &right)
 
 JulianDate (const TimeTag &right)
 
 JulianDate (const CommonTime &right)
 
JulianDateoperator= (const JulianDate &right)
 
virtual ~JulianDate ()
 Virtual Destructor. More...
 
virtual CommonTime convertToCommonTime () const
 
virtual void convertFromCommonTime (const CommonTime &ct)
 
virtual std::string printf (const std::string &fmt) const
 
virtual std::string printError (const std::string &fmt) const
 
virtual bool setFromInfo (const IdToValue &info)
 
virtual std::string getPrintChars () const
 
virtual std::string getDefaultFormat () const
 Return a string containing the default format to use in printing. More...
 
virtual bool isValid () const
 Returns true if this object's members are valid, false otherwise. More...
 
virtual void reset ()
 Reset this object to the default state. More...
 
- Public Member Functions inherited from gnsstk::TimeTag
virtual std::string asString () const
 
bool changeTimeSystem (TimeSystem timeSys)
 
bool changeTimeSystem (TimeSystem timeSys, TimeSystemConverter *conv)
 
TimeSystem getTimeSystem () const
 Obtain time system info (enum). More...
 
virtual operator CommonTime () const
 
virtual void scanf (const std::string &str, const std::string &fmt)
 
void setTimeSystem (const TimeSystem &timeSys)
 Set method for internal variable timeSystem (enum). More...
 
 TimeTag ()
 Default constructor. More...
 
 TimeTag (const TimeSystem &ts)
 Constructor. More...
 
virtual ~TimeTag ()
 Virtual Destructor. More...
 

JulianDate Comparison Operators

All comparison operators have a parameter "right" which corresponds to the JulianDate object to the right of the symbol. All comparison operators are const and return true on success and false on failure.

long double jd
 
bool operator== (const JulianDate &right) const
 
bool operator!= (const JulianDate &right) const
 
bool operator< (const JulianDate &right) const
 
bool operator> (const JulianDate &right) const
 
bool operator<= (const JulianDate &right) const
 
bool operator>= (const JulianDate &right) const
 

Additional Inherited Members

- Public Types inherited from gnsstk::TimeTag
typedef std::map< char, std::string > IdToValue
 
- Static Public Member Functions inherited from gnsstk::TimeTag
static void checkTimeSystem (TimeSystem ts1, TimeSystem ts2)
 
static std::string getError ()
 This returns the default error string for the TimeTag classes. More...
 
static std::string getFormatPrefixFloat ()
 
static std::string getFormatPrefixInt ()
 
static void getInfo (const std::string &str, const std::string &fmt, IdToValue &info)
 
- Protected Attributes inherited from gnsstk::TimeTag
TimeSystem timeSystem
 time system (representation) of the data More...
 

Constructor & Destructor Documentation

◆ JulianDate() [1/4]

gnsstk::JulianDate::JulianDate ( long double  j = 0.,
TimeSystem  ts = TimeSystem::Unknown 
)
inline

Default Constructor. All elements are initialized to zero.

Definition at line 100 of file JulianDate.hpp.

◆ JulianDate() [2/4]

gnsstk::JulianDate::JulianDate ( const JulianDate right)
inline

Copy Constructor.

Parameters
righta reference to the JulianDate object to copy

Definition at line 108 of file JulianDate.hpp.

◆ JulianDate() [3/4]

gnsstk::JulianDate::JulianDate ( const TimeTag right)
inline

Alternate Copy Constructor. Takes a const TimeTag reference and copies its contents via conversion to CommonTime.

Parameters
righta const reference to the BasicTime object to copy
Exceptions
InvalidRequeston over-/under-flow

Definition at line 119 of file JulianDate.hpp.

◆ JulianDate() [4/4]

gnsstk::JulianDate::JulianDate ( const CommonTime right)
inline

Alternate Copy Constructor. Takes a const CommonTime reference and copies its contents via the convertFromCommonTime method.

Parameters
righta const reference to the CommonTime object to copy
Exceptions
InvalidRequeston over-/under-flow

Definition at line 131 of file JulianDate.hpp.

◆ ~JulianDate()

virtual gnsstk::JulianDate::~JulianDate ( )
inlinevirtual

Virtual Destructor.

Definition at line 144 of file JulianDate.hpp.

Member Function Documentation

◆ convertFromCommonTime()

void gnsstk::JulianDate::convertFromCommonTime ( const CommonTime ct)
virtual
Exceptions
InvalidRequestif ct cannot be correctly represented in this TimeTag object.

Implements gnsstk::TimeTag.

Definition at line 76 of file JulianDate.cpp.

◆ convertToCommonTime()

CommonTime gnsstk::JulianDate::convertToCommonTime ( ) const
virtual
Exceptions
InvalidRequestif this TimeTag cannot be correctly represented by a CommonTime object.

Implements gnsstk::TimeTag.

Definition at line 54 of file JulianDate.cpp.

◆ getDefaultFormat()

virtual std::string gnsstk::JulianDate::getDefaultFormat ( ) const
inlinevirtual

Return a string containing the default format to use in printing.

Implements gnsstk::TimeTag.

Definition at line 177 of file JulianDate.hpp.

◆ getPrintChars()

virtual std::string gnsstk::JulianDate::getPrintChars ( ) const
inlinevirtual

Return a string containing the characters that this class understands when printing times.

Implements gnsstk::TimeTag.

Definition at line 171 of file JulianDate.hpp.

◆ isValid()

bool gnsstk::JulianDate::isValid ( ) const
virtual

Returns true if this object's members are valid, false otherwise.

Implements gnsstk::TimeTag.

Definition at line 151 of file JulianDate.cpp.

◆ operator!=()

bool gnsstk::JulianDate::operator!= ( const JulianDate right) const

Definition at line 183 of file JulianDate.cpp.

◆ operator<()

bool gnsstk::JulianDate::operator< ( const JulianDate right) const

Any (wildcard) type exception allowed, otherwise must be same time systems

Definition at line 188 of file JulianDate.cpp.

◆ operator<=()

bool gnsstk::JulianDate::operator<= ( const JulianDate right) const

Definition at line 211 of file JulianDate.cpp.

◆ operator=()

JulianDate & gnsstk::JulianDate::operator= ( const JulianDate right)

Assignment Operator.

Parameters
righta const reference to the JulianDate to copy
Returns
a reference to this JulianDate

Definition at line 47 of file JulianDate.cpp.

◆ operator==()

bool gnsstk::JulianDate::operator== ( const JulianDate right) const

Any (wildcard) type exception allowed, otherwise must be same time systems

Definition at line 168 of file JulianDate.cpp.

◆ operator>()

bool gnsstk::JulianDate::operator> ( const JulianDate right) const

Definition at line 206 of file JulianDate.cpp.

◆ operator>=()

bool gnsstk::JulianDate::operator>= ( const JulianDate right) const

Definition at line 217 of file JulianDate.cpp.

◆ printError()

std::string gnsstk::JulianDate::printError ( const std::string &  fmt) const
virtual

This function works similarly to printf. Instead of filling the format with data, it fills with error messages.

Implements gnsstk::TimeTag.

Definition at line 107 of file JulianDate.cpp.

◆ printf()

std::string gnsstk::JulianDate::printf ( const std::string &  fmt) const
virtual

This function formats this time to a string. The exceptions thrown would only be due to problems parsing the fmt string.

Implements gnsstk::TimeTag.

Definition at line 88 of file JulianDate.cpp.

◆ reset()

void gnsstk::JulianDate::reset ( )
virtual

Reset this object to the default state.

Implements gnsstk::TimeTag.

Definition at line 162 of file JulianDate.cpp.

◆ setFromInfo()

bool gnsstk::JulianDate::setFromInfo ( const IdToValue info)
virtual

Set this object using the information provided in info.

Parameters
infothe IdToValue object to which this object shall be set.
Returns
true if this object was successfully set using the data in info, false if not.

Implements gnsstk::TimeTag.

Definition at line 126 of file JulianDate.cpp.

Member Data Documentation

◆ jd

long double gnsstk::JulianDate::jd

Definition at line 202 of file JulianDate.hpp.


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


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:45