![]() |
SuperNOVAS C++ API v1.6
High-precision C/C++ astrometry library
|
A time specified in a specific type of calendar (Gregorian, Roman, or astronomical). More...
#include <supernovas.h>
Public Member Functions | |
| CalendarDate (const Calendar &calendar, double jd) | |
| Instantiates a date / time in the specified calendar, using the specified Julian Date. | |
| CalendarDate (const Calendar &calendar, int year, int month, int day, const TimeAngle &time=TimeAngle::zero()) | |
| Instantiates a date / time in the specified calendar, using the specified date components. | |
| int | break_down (struct tm *tm) const |
| Returns the standard POSIX broken-down time representation for this date. | |
| const Calendar & | calendar () const |
| const std::string & | day_name () const |
| Returns the full (English) name of the day of the week for this date. | |
| int | day_of_month () const |
| Returns the day of month component [1:32] of this date. | |
| int | day_of_week () const |
| Returns the day of week number [1:7] of this date, starting from 1 (Monday) to 7 (Sunday). | |
| int | day_of_year () const |
| Returns the day of year number [1:366] of this date. | |
| bool | equals (const CalendarDate &date, const Interval &precision) const |
| Checks if this calendar date is the same as the specified other date, within the specified tolerance. | |
| bool | equals (const CalendarDate &date, double seconds=Unit::ms) const |
| Checks if this calendar date is the same as the specified other date, within the specified tolerance. | |
| double | jd () const |
| Returns the Julian Day corresponding to this calendar date. | |
| double | mjd () const |
| Returns the Modified Julian Day corresponding to this calendar date. | |
| int | month () const |
| Returns the calendar month component [1:12] of this date. | |
| const std::string & | month_name () const |
| Returns the full (English) name of the month for this date. | |
| bool | operator!= (const CalendarDate &date) const |
| Checks if this calendar date differs from the specified other date, by more than 1 ms. | |
| CalendarDate | operator+ (const Interval &interval) const |
| Returns a new calendar date that is offset from this calendar date by the specified time interval. | |
| Interval | operator- (const CalendarDate &date) const |
| Returns the difference in time between this calendar date and the specified other calendar date. | |
| CalendarDate | operator- (const Interval &interval) const |
| Returns a new calendar date that is offset, back in time, from this calendar date by the specified time interval. | |
| bool | operator< (const CalendarDate &date) const |
| Checks if this calendar date is before the specified other date. | |
| bool | operator<= (const CalendarDate &date) const |
| Checks if this calendar date is the same or before the specified other date at 1 ms resolution. | |
| bool | operator== (const CalendarDate &date) const |
| Checks if this calendar date is the same as the specified other date, within 1 ms. | |
| bool | operator> (const CalendarDate &date) const |
| Checks if this calendar date is after the specified other date. | |
| bool | operator>= (const CalendarDate &date) const |
| Checks if this calendar date is the same or after the specified other date at 1 ms resolution. | |
| CalendarDate | operator>> (const Calendar &calendar) const |
| Returns this date in the specified other calendar. | |
| const std::string & | short_day_name () const |
| Returns the short 3-letter (English) abbreviation of the day of the week for this date. | |
| const std::string & | short_month_name () const |
| Returns the short 3-letter (English) abbreviation of the month name for this date. | |
| const TimeAngle & | time_of_day () const |
| Returns the time-of-dat component of this calendar date. | |
| CalendarDate | to_calendar (const Calendar &calendar) const |
| Returns this date in the specified other calendar. | |
| std::string | to_date_string (enum novas_date_format fmt=NOVAS_YMD) const |
| Returns the numerical date only representation, in the specified component order, e.g. | |
| std::string | to_long_date_string () const |
| Returns the date component in long-form string representation. | |
| std::string | to_string (enum novas_date_format fmt=NOVAS_YMD, int decimals=0) const |
| Returns a string representation of this calendar date, given the requested date format and decimal places to print for the seconds component. | |
| std::string | to_string (int decimals) const |
| Returns a string representation of this calendar date, using the YMD format and the specified decimal places to print for the seconds component. | |
| Time | to_time (const EOP &eop, novas_timescale timescale=NOVAS_UTC) const |
| Converts this calendar date to ans astronomical time representation, given the specified Earth Orientation Parameters, and astronomical timescale. | |
| Time | to_time (int leap_seconds, double dut1, novas_timescale timescale=NOVAS_UTC) const |
| Converts this calendar date to ans astronomical time representation, given the specified Earth Orientation Parameters, and astronomical timescale. | |
| time_t | unix_time () const |
| Returns the UNIX time for this calendar date. | |
| int | year () const |
| Returns the calendar year component of this date. | |
| Public Member Functions inherited from supernovas::Validating | |
| bool | is_valid () const |
| Returns the previously set 'valid' stae of the implementing instance. | |
| operator bool () const | |
| Objects that implement Validating can be used in conditionals directly, without explicitly calling is_valid(). | |
Static Public Member Functions | |
| static const CalendarDate & | undefined () |
| Returns a reference to a statically defined standard undefined / invalid calendar date instance. | |
Additional Inherited Members | |
| Protected Member Functions inherited from supernovas::Validating | |
| Validating () | |
| dummy constructor; | |
| Protected Attributes inherited from supernovas::Validating | |
| bool | _valid = false |
| the state variable. | |
A time specified in a specific type of calendar (Gregorian, Roman, or astronomical).
Calendar dates allow for broken-down (year, month, day-of-month, day-of-week, day-of-year, and time-of-day) representation. Unlike the related Time class, calendar dates are not timescale aware. They may be used typically to refer to UTC dates, or else whatevertimescale the user had in mind when constructing it. It has a lesser precision than Time, at the 100 μs level, limited by the double-precision representation of Julian dates. However, that level of precision is still sufficient for most applications.
| supernovas::CalendarDate::CalendarDate | ( | const Calendar & | calendar, |
| int | year, | ||
| int | month, | ||
| int | day, | ||
| const TimeAngle & | time = TimeAngle::zero() ) |
Instantiates a date / time in the specified calendar, using the specified date components.
| calendar | calendar, in which the date is specified. |
| year | [yr] calendar year |
| month | [month] calendar month [1:12] |
| day | [day] calendar day-of-month [1:31] |
| Time of observation and astronomical timescales | time of day component. |
References supernovas::Validating::_valid, calendar(), supernovas::TimeAngle::hours(), month(), novas_jd_from_date(), and year().
| supernovas::CalendarDate::CalendarDate | ( | const Calendar & | calendar, |
| double | jd ) |
Instantiates a date / time in the specified calendar, using the specified Julian Date.
| calendar | calendar, in which the date is specified. |
| jd | [day] Julian date (in the timescale of preference). |
References supernovas::Validating::_valid, calendar(), supernovas::Unit::hour, jd(), and novas_jd_to_date().
| int supernovas::CalendarDate::break_down | ( | struct tm * | tm | ) | const |
Returns the standard POSIX broken-down time representation for this date.
| [out] | tm | Pointer to the broken-down time structure in which to return the result. |
References supernovas::Validating::_valid, day_of_week(), and day_of_year().
|
inline |
Referenced by CalendarDate(), CalendarDate(), operator+(), operator-(), operator>>(), and to_calendar().
| const std::string & supernovas::CalendarDate::day_name | ( | ) | const |
Returns the full (English) name of the day of the week for this date.
References day_of_week().
| int supernovas::CalendarDate::day_of_month | ( | ) | const |
Returns the day of month component [1:32] of this date.
| int supernovas::CalendarDate::day_of_week | ( | ) | const |
Returns the day of week number [1:7] of this date, starting from 1 (Monday) to 7 (Sunday).
References novas_day_of_week().
Referenced by break_down(), day_name(), and short_day_name().
| int supernovas::CalendarDate::day_of_year | ( | ) | const |
Returns the day of year number [1:366] of this date.
References novas_day_of_year().
Referenced by break_down().
| bool supernovas::CalendarDate::equals | ( | const CalendarDate & | date, |
| const Interval & | precision ) const |
Checks if this calendar date is the same as the specified other date, within the specified tolerance.
| date | the other date to compare to this one. |
| precision | tolerance for equality check (default: 1 ms). |
References equals(), and supernovas::Interval::seconds().
| bool supernovas::CalendarDate::equals | ( | const CalendarDate & | date, |
| double | seconds = Unit::ms ) const |
Checks if this calendar date is the same as the specified other date, within the specified tolerance.
| date | the other date to compare to this one. |
| seconds | [s] tolerance for equality check. |
References supernovas::Unit::day, and jd().
Referenced by equals(), operator!=(), and operator==().
| double supernovas::CalendarDate::jd | ( | ) | const |
Returns the Julian Day corresponding to this calendar date.
Referenced by CalendarDate(), equals(), operator+(), operator-(), operator-(), operator<(), operator<=(), operator>=(), and to_time().
| double supernovas::CalendarDate::mjd | ( | ) | const |
Returns the Modified Julian Day corresponding to this calendar date.
References NOVAS_JD_MJD0.
| int supernovas::CalendarDate::month | ( | ) | const |
Returns the calendar month component [1:12] of this date.
Referenced by CalendarDate().
| const std::string & supernovas::CalendarDate::month_name | ( | ) | const |
Returns the full (English) name of the month for this date.
| bool supernovas::CalendarDate::operator!= | ( | const CalendarDate & | date | ) | const |
Checks if this calendar date differs from the specified other date, by more than 1 ms.
| date | the other date to compare to this one. |
References equals().
| CalendarDate supernovas::CalendarDate::operator+ | ( | const Interval & | r | ) | const |
Returns a new calendar date that is offset from this calendar date by the specified time interval.
| r | the offset interval, on the righ-hand-side of the + operator. |
References calendar(), supernovas::Interval::days(), supernovas::Validating::is_valid(), and jd().
| Interval supernovas::CalendarDate::operator- | ( | const CalendarDate & | r | ) | const |
Returns the difference in time between this calendar date and the specified other calendar date.
| r | the other calendar date, on the right-hand-side of the - operator. |
References supernovas::Unit::day, supernovas::Validating::is_valid(), and jd().
| CalendarDate supernovas::CalendarDate::operator- | ( | const Interval & | r | ) | const |
Returns a new calendar date that is offset, back in time, from this calendar date by the specified time interval.
| r | the offset interval, on the righ-hand-side of the - operator. |
References calendar(), supernovas::Interval::days(), supernovas::Validating::is_valid(), and jd().
| bool supernovas::CalendarDate::operator< | ( | const CalendarDate & | date | ) | const |
Checks if this calendar date is before the specified other date.
| date | the other date to compare to this one. |
References jd().
| bool supernovas::CalendarDate::operator<= | ( | const CalendarDate & | date | ) | const |
Checks if this calendar date is the same or before the specified other date at 1 ms resolution.
| date | the other date to compare to this one. |
References supernovas::Unit::day, jd(), and supernovas::Unit::ms.
| bool supernovas::CalendarDate::operator== | ( | const CalendarDate & | date | ) | const |
Checks if this calendar date is the same as the specified other date, within 1 ms.
| date | the other date to compare to this one. |
References equals().
| bool supernovas::CalendarDate::operator> | ( | const CalendarDate & | date | ) | const |
Checks if this calendar date is after the specified other date.
| date | the other date to compare to this one. |
| bool supernovas::CalendarDate::operator>= | ( | const CalendarDate & | date | ) | const |
Checks if this calendar date is the same or after the specified other date at 1 ms resolution.
| date | the other date to compare to this one. |
References supernovas::Unit::day, jd(), and supernovas::Unit::ms.
| CalendarDate supernovas::CalendarDate::operator>> | ( | const Calendar & | calendar | ) | const |
Returns this date in the specified other calendar.
Same as to_calendar().
| calendar | a calendar in which to express this date |
References calendar(), supernovas::Validating::is_valid(), and to_calendar().
| const std::string & supernovas::CalendarDate::short_day_name | ( | ) | const |
Returns the short 3-letter (English) abbreviation of the day of the week for this date.
References day_of_week().
Referenced by to_long_date_string().
| const std::string & supernovas::CalendarDate::short_month_name | ( | ) | const |
Returns the short 3-letter (English) abbreviation of the month name for this date.
Referenced by to_long_date_string().
| const TimeAngle & supernovas::CalendarDate::time_of_day | ( | ) | const |
Returns the time-of-dat component of this calendar date.
| CalendarDate supernovas::CalendarDate::to_calendar | ( | const Calendar & | calendar | ) | const |
Returns this date in the specified other calendar.
| calendar | a calendar in which to express this date |
References calendar(), and supernovas::Validating::is_valid().
Referenced by operator>>().
| std::string supernovas::CalendarDate::to_date_string | ( | enum novas_date_format | fmt = NOVAS_YMD | ) | const |
Returns the numerical date only representation, in the specified component order, e.g.
as "2025-01-31" (for NOVAS_YMD), "31.01.2025" (for NOVAS_DMY), or as "1/31/2025" for NOVAS_MDY).
| fmt | The format / order of year (Y), month (M), and day (D) components. |
References NOVAS_DMY, NOVAS_MDY, and NOVAS_YMD.
Referenced by to_string().
| std::string supernovas::CalendarDate::to_long_date_string | ( | ) | const |
Returns the date component in long-form string representation.
E.g. "11 November 2026", or "12 September 490 BCE".
References short_day_name(), and short_month_name().
| std::string supernovas::CalendarDate::to_string | ( | enum novas_date_format | fmt = NOVAS_YMD, |
| int | decimals = 0 ) const |
Returns a string representation of this calendar date, given the requested date format and decimal places to print for the seconds component.
| fmt | (optional) The order of the date components (default: NOVAS_YMD) |
| decimals | (optional) Number of decimal places to print for the seconds (default: 3) |
References NOVAS_SEP_COLONS, and to_date_string().
Referenced by to_string().
| std::string supernovas::CalendarDate::to_string | ( | int | decimals | ) | const |
Returns a string representation of this calendar date, using the YMD format and the specified decimal places to print for the seconds component.
| decimals | Number of decimal places to print for the seconds. |
References NOVAS_YMD, and to_string().
| Time supernovas::CalendarDate::to_time | ( | const EOP & | eop, |
| novas_timescale | timescale = NOVAS_UTC ) const |
Converts this calendar date to ans astronomical time representation, given the specified Earth Orientation Parameters, and astronomical timescale.
Not, that calendar dates have accuracy at the 0.1 ms level only, hence the resulting astronomical time will be limited to the same level of precision also.
| eop | Earth Orientation Parameters (EOP) for this date. |
| timescale | the astronomical timescale in which this calendar date is defined. |
References supernovas::EOP::dUT1(), supernovas::EOP::leap_seconds(), supernovas::Interval::seconds(), and to_time().
| Time supernovas::CalendarDate::to_time | ( | int | leap_seconds, |
| double | dut1, | ||
| novas_timescale | timescale = NOVAS_UTC ) const |
Converts this calendar date to ans astronomical time representation, given the specified Earth Orientation Parameters, and astronomical timescale.
Not, that calendar dates have accuracy at the 0.1 ms level only, hence the resulting astronomical time will be limited to the same level of precision also.
| leap_seconds | [s] the leap seconds of date, that is the TAI - UTC time difference. |
| dut1 | [s] the UT1 - UTC time difference for the date |
| timescale | the astronomical timescale in which this calendar date is defined. |
References supernovas::Validating::is_valid(), and jd().
Referenced by to_time().
|
static |
Returns a reference to a statically defined standard undefined / invalid calendar date instance.
Referenced by supernovas::Calendar::parse_date().
| time_t supernovas::CalendarDate::unix_time | ( | ) | const |
Returns the UNIX time for this calendar date.
References supernovas::Unit::day, NOVAS_JD_J2000, and UNIX_UTC_J2000.
| int supernovas::CalendarDate::year | ( | ) | const |
Returns the calendar year component of this date.
Referenced by CalendarDate().