Class to handle Julian days and provide respective Earth Orientation Parameters (EOP). More...
#include "julian-date.h"
Public Member Functions | |
JulianDate (const std::string &date, TimeSystem ts=DateTime::UTC) | |
JulianDate constructor receiving time as a Gregorian date. More... | |
JulianDate (double jd) | |
JulianDate constructor receiving the Julian days as parameter. More... | |
JulianDate (uint32_t days, uint32_t ms_day) | |
JulianDate constructor receiving time since Unix/POSIX epoch. More... | |
JulianDate (void) | |
Default constructor. More... | |
DateTime | GetDateTime (TimeSystem ts) const |
Get the Gregorian calendar date in the specified time system. More... | |
DateTime | GetDateTime (void) const |
Get the Gregorian calendar date in current time system. More... | |
double | GetDouble (TimeSystem ts=DateTime::UTC) const |
GetDouble Get the Julian days. More... | |
double | GetGmst (void) const |
Retrieve the Greenwich Mean Sidereal Time. More... | |
double | GetOmegaEarth (void) const |
Retrieve Earth's angular velocity. More... | |
std::pair< double, double > | GetPolarMotion (void) const |
Retrieve the polar motion cofficients measured/predicted. More... | |
bool | operator!= (const JulianDate &jd) const |
operator != (compare Julian dates). More... | |
JulianDate | operator+ (const Time &t) const |
operator + (positive time adjustment). More... | |
void | operator+= (const Time &t) |
operator += (positive time adjustment). More... | |
Time | operator- (const JulianDate &jd) const |
operator - (time between Julian dates). More... | |
JulianDate | operator- (const Time &t) const |
operator - (negative time adjustment). More... | |
void | operator-= (const Time &t) |
operator -= (negative time adjustment). More... | |
bool | operator< (const JulianDate &jd) const |
operator < (compare Julian dates). More... | |
bool | operator<= (const JulianDate &jd) const |
operator <= (compare Julian dates). More... | |
bool | operator== (const JulianDate &jd) const |
operator == (compare Julian dates). More... | |
bool | operator> (const JulianDate &jd) const |
operator > (compare Julian dates). More... | |
bool | operator>= (const JulianDate &jd) const |
operator >= (compare Julian dates). More... | |
void | SetDate (const std::string &date, TimeSystem ts=DateTime::UTC) |
Set Julian days using time in Gregorian calendar date. More... | |
void | SetDate (double jd) |
Set the Julian days. More... | |
void | SetDate (uint32_t days, uint32_t ms_day) |
Set Julian days using the time since Unix/POSIX epoch. More... | |
std::string | ToString (TimeSystem ts) const |
Get the string representation of the Gregorian calendar date in time system ts. More... | |
std::string | ToString (void) const |
Get the string representation of the Gregorian calendar date. More... | |
Static Public Attributes | |
static const uint32_t | DayToMs = HourToMs * 24 |
milliseconds in a day More... | |
static const uint32_t | HourToMs = 3600000 |
milliseconds in an hour More... | |
static const uint32_t | J2000Epoch = 2451545 |
1 Jan 2000, 12h More... | |
static const uint32_t | MaxYear = 2099 |
Maximum year supported. More... | |
static const uint32_t | MinYear = 1992 |
Minimum year supported. More... | |
static const uint32_t | Posix1992 = 8035 |
1 Jan 1992 (POSIX days) More... | |
static const double | PosixEpoch = 2440587.5 |
1 Jan 1970, 0h More... | |
static const uint32_t | PosixYear = 1970 |
POSIX/Unix epoch year. More... | |
static const Time | TaiToGps = MilliSeconds(19000) |
offset from TAI to GPST More... | |
static const Time | TtToTai = MilliSeconds(32184) |
offset from TT to TAI More... | |
Private Types | |
typedef DateTime::TimeSystem | TimeSystem |
equivalent to C++11 using TimeSystem = DateTime::TimeSystem. More... | |
Private Member Functions | |
DateTime | GregorianDate (void) const |
Convert into Gregorian calendar. More... | |
Time | OffsetFromUtc (void) const |
Returns the offset from UTC. More... | |
Time | OffsetToUtc (void) const |
Returns the offset to UTC. More... | |
Static Private Member Functions | |
static Time | Dut1 (uint32_t daysInPosix) |
Retrieve the DUT1 (UT1 - UTC) value for a given day. More... | |
static DateTime | GregorianDate (uint32_t days, uint32_t ms_day) |
Convert Julian days into Gregorian calendar. More... | |
static bool | IsLeapYear (uint32_t year) |
Check if it is a leap year. More... | |
static Time | OffsetFromUtc (uint32_t daysInPosix, TimeSystem ts) |
Returns the offset from UTC for a given time. More... | |
static Time | OffsetToUtc (uint32_t daysInPosix, uint32_t ms_day, TimeSystem ts) |
Returns the offset to UTC for a given time. More... | |
static Time | TaiMinusUtc (uint32_t daysInPosix) |
The difference between TAI and UTC time systems. More... | |
Private Attributes | |
uint32_t | m_days |
full days since epoch. More... | |
uint32_t | m_ms_day |
milliseconds of the day. More... | |
TimeSystem | m_time_scale |
external time system. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const JulianDate &jd) |
operator << (print as GregorianDate). More... | |
Class to handle Julian days and provide respective Earth Orientation Parameters (EOP).
This class provides an easy interface to convert between Julian days and Gregorian dates in UTC, UT1, TAI, TT, GPST, and Unix/POSIX time, and, using IersData class, provides the respective Earth Orientation Parameters (EOP). The EOP parameters available are: DUT1, Earth's angular velocity, and Greenwich Mean Sidereal Time (GMST).
IMPORTANT: Complete EOP values are only available since 1 January 1992, therefore, this class only supports dates from 1 January 1992 up to 31 December 2099.
Definition at line 78 of file julian-date.h.
|
private |
equivalent to C++11 using TimeSystem = DateTime::TimeSystem.
Definition at line 81 of file julian-date.h.
ns3::JulianDate::JulianDate | ( | void | ) |
Default constructor.
Definition at line 89 of file julian-date.cc.
References m_days, m_ms_day, m_time_scale, MinYear, PosixYear, and ns3::DateTime::UTC.
ns3::JulianDate::JulianDate | ( | double | jd | ) |
JulianDate constructor receiving the Julian days as parameter.
This constructor has lower precision as there may be some inaccuracy at the millisecond level due to double type limited precision.
jd | The Julian days. |
Definition at line 97 of file julian-date.cc.
References SetDate().
ns3::JulianDate::JulianDate | ( | uint32_t | days, |
uint32_t | ms_day | ||
) |
JulianDate constructor receiving time since Unix/POSIX epoch.
days | Full days since Unix/POSIX epoch (1 January 1970, 0h). |
ms_day | Milliseconds of the day (since midnight). |
Definition at line 102 of file julian-date.cc.
References SetDate().
ns3::JulianDate::JulianDate | ( | const std::string & | date, |
TimeSystem | ts = DateTime::UTC |
||
) |
JulianDate constructor receiving time as a Gregorian date.
date | Gregorian calendar date. |
ts | Time system of the date (UTC, UT1, TAI, TT or GPST). |
Definition at line 107 of file julian-date.cc.
References SetDate().
|
staticprivate |
Retrieve the DUT1 (UT1 - UTC) value for a given day.
daysInPosix | number of full days since Unix/POSIX epoch. |
Definition at line 424 of file julian-date.cc.
References ns3::IersData::EopValues, and Posix1992.
Referenced by GetGmst(), OffsetFromUtc(), and OffsetToUtc().
DateTime ns3::JulianDate::GetDateTime | ( | TimeSystem | ts | ) | const |
Get the Gregorian calendar date in the specified time system.
Definition at line 131 of file julian-date.cc.
References m_days, and OffsetFromUtc().
DateTime ns3::JulianDate::GetDateTime | ( | void | ) | const |
Get the Gregorian calendar date in current time system.
Definition at line 125 of file julian-date.cc.
References GregorianDate().
double ns3::JulianDate::GetDouble | ( | TimeSystem | ts = DateTime::UTC | ) | const |
GetDouble Get the Julian days.
ts | Time system to consider for conversion (UTC by default). |
Definition at line 113 of file julian-date.cc.
References DayToMs, m_days, m_ms_day, OffsetFromUtc(), ns3::DateTime::POSIX, and PosixEpoch.
Referenced by GetGmst().
double ns3::JulianDate::GetGmst | ( | void | ) | const |
Retrieve the Greenwich Mean Sidereal Time.
@TODO interpolate DUT1 between daily values
@TODO evaluate which formula is more accurate
Definition at line 187 of file julian-date.cc.
References Dut1(), GetDouble(), gstime(), and m_days.
Referenced by ns3::SatSGP4MobilityModel::TemeToPef().
double ns3::JulianDate::GetOmegaEarth | ( | void | ) | const |
Retrieve Earth's angular velocity.
Definition at line 174 of file julian-date.cc.
References DayToMs, ns3::IersData::EopValues, m_days, and Posix1992.
Referenced by ns3::SatSGP4MobilityModel::rvTemeTovItrf().
std::pair< double, double > ns3::JulianDate::GetPolarMotion | ( | void | ) | const |
Retrieve the polar motion cofficients measured/predicted.
Definition at line 161 of file julian-date.cc.
References ns3::IersData::EopValues, m_days, and Posix1992.
Referenced by ns3::SatSGP4MobilityModel::PefToItrf().
|
staticprivate |
Convert Julian days into Gregorian calendar.
days | Full Julian days. |
ms_day | Milliseconds of the day (since midnight). |
Definition at line 439 of file julian-date.cc.
References ns3::DateTime::day, ns3::DateTime::hours, IsLeapYear(), ns3::DateTime::millisecs, ns3::DateTime::minutes, MinYear, ns3::DateTime::month, Posix1992, ns3::DateTime::seconds, and ns3::DateTime::year.
|
private |
Convert into Gregorian calendar.
Definition at line 433 of file julian-date.cc.
References m_days, and m_ms_day.
Referenced by GetDateTime(), and ToString().
|
staticprivate |
Check if it is a leap year.
This function assumes that the year is in the [1992, 2099] range.
year | the year to check. |
Definition at line 405 of file julian-date.cc.
Referenced by GregorianDate().
|
staticprivate |
Returns the offset from UTC for a given time.
daysInPosix | Full days since Unix/POSIX epoch. |
ts | Time system from. |
Definition at line 491 of file julian-date.cc.
References Dut1(), ns3::DateTime::GPST, ns3::DateTime::TAI, TaiMinusUtc(), TaiToGps, ns3::DateTime::TT, TtToTai, and ns3::DateTime::UT1.
|
private |
Returns the offset from UTC.
Returns the offset from UTC to its internal time system as of its internal time.
Definition at line 485 of file julian-date.cc.
References m_days, and m_time_scale.
Referenced by GetDateTime(), GetDouble(), and ToString().
|
staticprivate |
Returns the offset to UTC for a given time.
daysInPosix | Full days since Unix/POSIX epoch. |
ms_day | Milliseconds of the day (since midnight). |
ts | Time system to. |
Definition at line 524 of file julian-date.cc.
References Dut1(), ns3::DateTime::GPST, ns3::DateTime::POSIX, ns3::DateTime::TAI, TaiMinusUtc(), TaiToGps, ns3::DateTime::TT, TtToTai, ns3::DateTime::UT1, and ns3::DateTime::UTC.
|
private |
Returns the offset to UTC.
Returns the offset to UTC from its internal time system as of its internal time.
Definition at line 518 of file julian-date.cc.
References m_days, m_ms_day, and m_time_scale.
Referenced by SetDate().
bool ns3::JulianDate::operator!= | ( | const JulianDate & | jd | ) | const |
operator != (compare Julian dates).
jd | Julian days. |
Definition at line 384 of file julian-date.cc.
JulianDate ns3::JulianDate::operator+ | ( | const Time & | t | ) | const |
operator + (positive time adjustment).
t | time adjustment. |
Definition at line 272 of file julian-date.cc.
References DayToMs, m_days, m_ms_day, and m_time_scale.
void ns3::JulianDate::operator+= | ( | const Time & | t | ) |
operator += (positive time adjustment).
t | time adjustment. |
Definition at line 292 of file julian-date.cc.
Time ns3::JulianDate::operator- | ( | const JulianDate & | jd | ) | const |
operator - (time between Julian dates).
jd | Julian days. |
Definition at line 330 of file julian-date.cc.
JulianDate ns3::JulianDate::operator- | ( | const Time & | t | ) | const |
operator - (negative time adjustment).
t | time adjustment. |
Definition at line 298 of file julian-date.cc.
References DayToMs, m_days, m_ms_day, and m_time_scale.
void ns3::JulianDate::operator-= | ( | const Time & | t | ) |
operator -= (negative time adjustment).
t | time adjustment. |
Definition at line 324 of file julian-date.cc.
bool ns3::JulianDate::operator< | ( | const JulianDate & | jd | ) | const |
operator < (compare Julian dates).
jd | Julian days. |
Definition at line 338 of file julian-date.cc.
bool ns3::JulianDate::operator<= | ( | const JulianDate & | jd | ) | const |
operator <= (compare Julian dates).
jd | Julian days. |
Definition at line 347 of file julian-date.cc.
bool ns3::JulianDate::operator== | ( | const JulianDate & | jd | ) | const |
operator == (compare Julian dates).
jd | Julian days. |
Definition at line 375 of file julian-date.cc.
bool ns3::JulianDate::operator> | ( | const JulianDate & | jd | ) | const |
operator > (compare Julian dates).
jd | Julian days. |
Definition at line 357 of file julian-date.cc.
bool ns3::JulianDate::operator>= | ( | const JulianDate & | jd | ) | const |
operator >= (compare Julian dates).
jd | Julian days. |
Definition at line 366 of file julian-date.cc.
void ns3::JulianDate::SetDate | ( | const std::string & | date, |
TimeSystem | ts = DateTime::UTC |
||
) |
Set Julian days using time in Gregorian calendar date.
date | Gregorian calendar date. |
ts | Time system of the date (UTC, UT1, TAI, TT or GPST). |
Definition at line 238 of file julian-date.cc.
References ns3::DateTime::day, ns3::DateTime::hours, m_days, m_ms_day, m_time_scale, MaxYear, ns3::DateTime::millisecs, ns3::DateTime::minutes, MinYear, ns3::DateTime::month, OffsetToUtc(), ns3::DateTime::POSIX, PosixEpoch, ns3::DateTime::seconds, and ns3::DateTime::year.
void ns3::JulianDate::SetDate | ( | double | jd | ) |
Set the Julian days.
This function has lower precision as there may be some inaccuracy at the millisecond level due to double type limited precision.
jd | The Julian days. |
Definition at line 218 of file julian-date.cc.
References DayToMs, m_days, m_ms_day, m_time_scale, PosixEpoch, and ns3::DateTime::UTC.
Referenced by JulianDate().
void ns3::JulianDate::SetDate | ( | uint32_t | days, |
uint32_t | ms_day | ||
) |
Set Julian days using the time since Unix/POSIX epoch.
days | Full days since Unix/POSIX epoch (1 January 1970, 0h). |
ms_day | Milliseconds of the day (since midnight). |
Definition at line 229 of file julian-date.cc.
References m_days, m_ms_day, m_time_scale, and ns3::DateTime::POSIX.
|
staticprivate |
The difference between TAI and UTC time systems.
daysInPosix | Full days since Unix/POSIX epoch. |
Definition at line 413 of file julian-date.cc.
References ns3::IersData::BaseLeapSeconds, and ns3::IersData::LeapSeconds.
Referenced by OffsetFromUtc(), and OffsetToUtc().
std::string ns3::JulianDate::ToString | ( | TimeSystem | ts | ) | const |
Get the string representation of the Gregorian calendar date in time system ts.
The string is formatted as "YYYY-MM-DD hh:mm:ss.ms TTT", where YYYY is the year, MM the month, DD the day of the month, hh the hour of the day, mm the minutes of the day, ss the seconds of the day, and ms the milliseconds.
Definition at line 151 of file julian-date.cc.
References m_time_scale, and ToString().
std::string ns3::JulianDate::ToString | ( | void | ) | const |
Get the string representation of the Gregorian calendar date.
The string is formatted as "YYYY-MM-DD hh:mm:ss.ms TTT", where YYYY is the year, MM the month, DD the day of the month, hh the hour of the day, mm the minutes of the day, ss the seconds of the day, and ms the milliseconds.
Definition at line 137 of file julian-date.cc.
References ns3::DateTime::day, GregorianDate(), ns3::DateTime::hours, m_time_scale, ns3::DateTime::millisecs, ns3::DateTime::minutes, ns3::DateTime::month, OffsetFromUtc(), ns3::DateTime::seconds, and ns3::DateTime::year.
Referenced by ToString().
|
friend |
operator << (print as GregorianDate).
Print the textual representation (Gregorian calendar date) using the time system specified upon creation or setting.
os | Output stream object. |
jd | Julian date object. |
Definition at line 392 of file julian-date.cc.
|
static |
milliseconds in a day
millisecs in a day
Definition at line 91 of file julian-date.h.
Referenced by GetDouble(), GetOmegaEarth(), operator+(), operator-(), and SetDate().
|
static |
|
static |
1 Jan 2000, 12h
Definition at line 88 of file julian-date.h.
|
private |
full days since epoch.
Definition at line 371 of file julian-date.h.
Referenced by JulianDate(), GetDateTime(), GetDouble(), GetGmst(), GetOmegaEarth(), GetPolarMotion(), GregorianDate(), OffsetFromUtc(), OffsetToUtc(), operator!=(), operator+(), operator-(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and SetDate().
|
private |
milliseconds of the day.
Definition at line 372 of file julian-date.h.
Referenced by JulianDate(), GetDouble(), GregorianDate(), OffsetToUtc(), operator!=(), operator+(), operator-(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and SetDate().
|
private |
external time system.
Definition at line 373 of file julian-date.h.
Referenced by JulianDate(), OffsetFromUtc(), OffsetToUtc(), operator+(), operator-(), SetDate(), and ToString().
|
static |
Maximum year supported.
maximum year
Definition at line 86 of file julian-date.h.
Referenced by SetDate().
|
static |
Minimum year supported.
IERS data since.
Definition at line 85 of file julian-date.h.
Referenced by JulianDate(), GregorianDate(), and SetDate().
|
static |
1 Jan 1992 (POSIX days)
1 Jan 1992 (Unix days)
Definition at line 89 of file julian-date.h.
Referenced by Dut1(), GetOmegaEarth(), GetPolarMotion(), and GregorianDate().
|
static |
1 Jan 1970, 0h
Definition at line 87 of file julian-date.h.
Referenced by GetDouble(), and SetDate().
|
static |
POSIX/Unix epoch year.
POSIX epoch year.
Definition at line 84 of file julian-date.h.
Referenced by JulianDate().
|
static |
offset from TAI to GPST
TAI - GPST (in ms)
Definition at line 93 of file julian-date.h.
Referenced by OffsetFromUtc(), and OffsetToUtc().
|
static |
offset from TT to TAI
TT - TAI (in ms)
Definition at line 92 of file julian-date.h.
Referenced by OffsetFromUtc(), and OffsetToUtc().