📄 jdate.h
字号:
/* Constructor * * Initialize the date as the specified JulianDayNumber structure */ JDate( const JulianDayNumber& julianDayNumber); /* Destructor * */ ~JDate();
/* Sets the file to use to offset the time for virtual time
*
* @param file The timeoffset file to use
*
*/
static void
setTimeOffsetFile(
const string &file);
/* Returns the real seconds for the number of virtual seconds is equal to * This uses the time offset functionality. * If the time offset is disabled, then 1s virtual = 1s real * * @param virtualSecs The number of virtual seconds to convert to real seconds * * @returns The number of real seconds the virtual seconds are equal to */ static unsigned long getRealSecondsForVirtualSeconds( const long virtualSecs);
/* Determine if a year is a leap year according to the julian calander
*
* @param year Astronomers year to test
*
* @returns Returns true if the given year is a gregorian leap year
*/
static bool
isJulianLeapYear(
long astronomersYear);
/* Determine if a year is a leap year according to the gregorian calander * * @param year Astronomers year to test * * @returns Returns true if the given year is a gregorian leap year */ static bool isGregorianLeapYear( long astronomersYear); /* Return a string representation of the internal date * * @param fmt Optional format parameter. Defaults to FMT_DATE_ISO * * @returns Formated string representation of the internal JD. */ string asString( const string &fmt = DT_FMT_DATETIME_ISO); /* Return a double representing the julian day number * * @returns Julian Day Number. (JD) */ double asJulianDayNumber(); /* Return the unix timestamp if within range * * @returns UnixTimeStamp */ time_t asUnixTimeStamp(); /* Return the date in its individual components * */ void asComponents( int& year, int& month, int& day, int& hour, int& minute, int& second); /* Return the part of the date requested (ie. SECONDS, MINS, etc.) * * @returns The date part unit as requested */ int asComponent( Units unit); /* Return a JulianDayNumber struct * * @returns JulianDayNumber struct */ JulianDayNumber asJulianDayNumberStruct(); /* Sets the date as a string * * @param dateStr String representing the date in the format as in fmt * @param fmt Optional format parameter. Defaults to FMT_DATE_ISO * */ void setDate( const string &dateStr, const string &fmt = SET_FMT_DATETIME_ISO); /* Sets the date from a unix timestamp * * @unixTime Unix timestamp to set the time to. * @timeZone Optional timezone the date elements represent * */ void setDate( const time_t unixTime, int timeZone = 0); /* Sets the date from a Julian Day Number with time fraction * * @julianDayNumber JD to set the date to * */ void setDate( const double julianDayNumber); /* Sets the date from individual date parameters. * * @param year * @param month * @param day * @param hour * @param minute * @param second * @timeZone Optional timezone the date elements represent * */ void setDate( int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int timeZone = 0); /* Sets the date from another jDate object * * @param dateObj jDate Object to set the date from * */ void setDate( const JDate &dateObj); /* Sets the date from a JulianDayNumber structure * * @param JulianDayNumber The strucutre holding the julian day number and seconds * */ void setDate( const JulianDayNumber& julianDayNumber); /* Increases the stored date by the given number of unit types * * @param unit Unit type to increase the date by * @param numUnits Units to increase the date by * */ void modifyDate( Units unit, const long numUnits); /* Assignment operator to assign a string * * @param dateStr date in the format of DT_FMT_DATETIME_ISO * */ void operator=( const char* dateStr); /* Assignment operator to assign a string * * @param dateStr date in the format of DT_FMT_DATETIME_ISO * */ void operator=( const string &dateStr); /* Assignment operator to assign a unix time stamp and convert it to a JD * This converts using local time. * * @param time_t unix time stamp to assign * */ void operator=( time_t unixTime); /* Assignment operator to assign a date from a JD * * @param julianDayNumber Julian Day number to assign * */ void operator=( const double julianDayNumber); /* Assignment operator to assign a date from a JulianDayNumber structure * * @param julianDayNumber Julian Day number strucuture to assign * */ void operator=( const JulianDayNumber julianDayNumber); /* Arithmetic Addition Operator * * @returns A new JDate object with the two dates added together. * */ JDate operator+( const JDate &x); /* Arithmetic Subtraction Operator * * @returns A new JDate object with the two dates subtracted from each together. * */ JDate operator-( const JDate &x); /* Arithmetic Addition Assignment Operator * * @returns A new JDate object with the two dates added together. * */ JDate operator+=( const JDate &x); /* Arithmetic Subtraction Assignment Operator * * @returns A new JDate object with the two dates added together. * */ JDate operator-=( const JDate &x); /* Comparison Greater than Operator * * @returns 0 for false and 1 for true * */ int operator>( const JDate &x); /* Comparison Greater than Equal Operator * * @returns 0 for false and 1 for true * */ int operator>=( const JDate &x); /* Comparison Less than Operator * * @returns 0 for false and 1 for true * */ int operator<( const JDate &x); /* Comparison Len than Equal Operator * * @returns 0 for false and 1 for true * */ int operator<=( const JDate &x); /* Comparison Equal Operator * * @returns 0 for false and 1 for true * */ int operator==( const JDate &x); /* Comparison Not Equal Operator * * @returns 0 for false and 1 for true * */ int operator!=( const JDate &x);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -