ns3::JulianDate Class Reference

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...
 

Detailed Description

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 77 of file julian-date.h.

Member Typedef Documentation

◆ TimeSystem

equivalent to C++11 using TimeSystem = DateTime::TimeSystem.

Definition at line 80 of file julian-date.h.

Constructor & Destructor Documentation

◆ JulianDate() [1/4]

ns3::JulianDate::JulianDate ( void  )

Default constructor.

Definition at line 85 of file julian-date.cc.

References m_days, m_ms_day, m_time_scale, MinYear, PosixYear, and ns3::DateTime::UTC.

◆ JulianDate() [2/4]

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.

Parameters
jdThe Julian days.

Definition at line 93 of file julian-date.cc.

References SetDate().

+ Here is the call graph for this function:

◆ JulianDate() [3/4]

ns3::JulianDate::JulianDate ( uint32_t  days,
uint32_t  ms_day 
)

JulianDate constructor receiving time since Unix/POSIX epoch.

Parameters
daysFull days since Unix/POSIX epoch (1 January 1970, 0h).
ms_dayMilliseconds of the day (since midnight).

Definition at line 98 of file julian-date.cc.

References SetDate().

+ Here is the call graph for this function:

◆ JulianDate() [4/4]

ns3::JulianDate::JulianDate ( const std::string &  date,
TimeSystem  ts = DateTime::UTC 
)

JulianDate constructor receiving time as a Gregorian date.

Parameters
dateGregorian calendar date.
tsTime system of the date (UTC, UT1, TAI, TT or GPST).

Definition at line 103 of file julian-date.cc.

References SetDate().

+ Here is the call graph for this function:

Member Function Documentation

◆ Dut1()

Time ns3::JulianDate::Dut1 ( uint32_t  daysInPosix)
staticprivate

Retrieve the DUT1 (UT1 - UTC) value for a given day.

Parameters
daysInPosixnumber of full days since Unix/POSIX epoch.
Returns
the DUT1 measured/predicted as of IERS Bulletin A.

Definition at line 420 of file julian-date.cc.

References ns3::IersData::EopValues, and Posix1992.

Referenced by GetGmst(), OffsetFromUtc(), and OffsetToUtc().

+ Here is the caller graph for this function:

◆ GetDateTime() [1/2]

DateTime ns3::JulianDate::GetDateTime ( TimeSystem  ts) const

Get the Gregorian calendar date in the specified time system.

Returns
a DateTime struct with the Gregorian calendar date.

Definition at line 127 of file julian-date.cc.

References m_days, and OffsetFromUtc().

+ Here is the call graph for this function:

◆ GetDateTime() [2/2]

DateTime ns3::JulianDate::GetDateTime ( void  ) const

Get the Gregorian calendar date in current time system.

Returns
a DateTime struct with the Gregorian calendar date and time.

Definition at line 121 of file julian-date.cc.

References GregorianDate().

+ Here is the call graph for this function:

◆ GetDouble()

double ns3::JulianDate::GetDouble ( TimeSystem  ts = DateTime::UTC) const

GetDouble Get the Julian days.

Parameters
tsTime system to consider for conversion (UTC by default).
Returns
the Julian days in time system ts.

Definition at line 109 of file julian-date.cc.

References DayToMs, m_days, m_ms_day, OffsetFromUtc(), ns3::DateTime::POSIX, and PosixEpoch.

Referenced by GetGmst().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGmst()

double ns3::JulianDate::GetGmst ( void  ) const

Retrieve the Greenwich Mean Sidereal Time.

Returns
the GMST using DUT1 values measured/predicted as IERS' Bulletin A.

@TODO interpolate DUT1 between daily values

@TODO evaluate which formula is more accurate

Definition at line 183 of file julian-date.cc.

References Dut1(), GetDouble(), gstime(), and m_days.

Referenced by ns3::SatSGP4MobilityModel::TemeToPef().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetOmegaEarth()

double ns3::JulianDate::GetOmegaEarth ( void  ) const

Retrieve Earth's angular velocity.

Returns
the Earth's angular velocity.

Definition at line 170 of file julian-date.cc.

References DayToMs, ns3::IersData::EopValues, m_days, and Posix1992.

Referenced by ns3::SatSGP4MobilityModel::rvTemeTovItrf().

+ Here is the caller graph for this function:

◆ GetPolarMotion()

std::pair< double, double > ns3::JulianDate::GetPolarMotion ( void  ) const

Retrieve the polar motion cofficients measured/predicted.

Returns
the polar motion values measured/predicted as IERS' Bulletin A.

Definition at line 157 of file julian-date.cc.

References ns3::IersData::EopValues, m_days, and Posix1992.

Referenced by ns3::SatSGP4MobilityModel::PefToItrf().

+ Here is the caller graph for this function:

◆ GregorianDate() [1/2]

DateTime ns3::JulianDate::GregorianDate ( uint32_t  days,
uint32_t  ms_day 
)
staticprivate

Convert Julian days into Gregorian calendar.

Parameters
daysFull Julian days.
ms_dayMilliseconds of the day (since midnight).
Returns
a DateTime struct with the date.

Definition at line 435 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.

+ Here is the call graph for this function:

◆ GregorianDate() [2/2]

DateTime ns3::JulianDate::GregorianDate ( void  ) const
private

Convert into Gregorian calendar.

Returns
a DateTime struct with the date.

Definition at line 429 of file julian-date.cc.

References m_days, and m_ms_day.

Referenced by GetDateTime(), and ToString().

+ Here is the caller graph for this function:

◆ IsLeapYear()

bool ns3::JulianDate::IsLeapYear ( uint32_t  year)
staticprivate

Check if it is a leap year.

This function assumes that the year is in the [1992, 2099] range.

Parameters
yearthe year to check.
Returns
a boolean indicating whether it is a leap year.

Definition at line 401 of file julian-date.cc.

Referenced by GregorianDate().

+ Here is the caller graph for this function:

◆ OffsetFromUtc() [1/2]

Time ns3::JulianDate::OffsetFromUtc ( uint32_t  daysInPosix,
TimeSystem  ts 
)
staticprivate

Returns the offset from UTC for a given time.

Parameters
daysInPosixFull days since Unix/POSIX epoch.
tsTime system from.
Returns
the offset from UTC.

Definition at line 487 of file julian-date.cc.

References Dut1(), ns3::DateTime::GPST, ns3::DateTime::TAI, TaiMinusUtc(), TaiToGps, ns3::DateTime::TT, TtToTai, and ns3::DateTime::UT1.

+ Here is the call graph for this function:

◆ OffsetFromUtc() [2/2]

Time ns3::JulianDate::OffsetFromUtc ( void  ) const
private

Returns the offset from UTC.

Returns the offset from UTC to its internal time system as of its internal time.

Returns
the offset from UTC.

Definition at line 481 of file julian-date.cc.

References m_days, and m_time_scale.

Referenced by GetDateTime(), GetDouble(), and ToString().

+ Here is the caller graph for this function:

◆ OffsetToUtc() [1/2]

Time ns3::JulianDate::OffsetToUtc ( uint32_t  daysInPosix,
uint32_t  ms_day,
TimeSystem  ts 
)
staticprivate

Returns the offset to UTC for a given time.

Parameters
daysInPosixFull days since Unix/POSIX epoch.
ms_dayMilliseconds of the day (since midnight).
tsTime system to.
Returns
the offset to UTC.

Definition at line 520 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.

+ Here is the call graph for this function:

◆ OffsetToUtc() [2/2]

Time ns3::JulianDate::OffsetToUtc ( void  ) const
private

Returns the offset to UTC.

Returns the offset to UTC from its internal time system as of its internal time.

Returns
the offset to UTC.

Definition at line 514 of file julian-date.cc.

References m_days, m_ms_day, and m_time_scale.

Referenced by SetDate().

+ Here is the caller graph for this function:

◆ operator!=()

bool ns3::JulianDate::operator!= ( const JulianDate jd) const

operator != (compare Julian dates).

Parameters
jdJulian days.
Returns
a boolean to indicate if the Julian date is different.

Definition at line 380 of file julian-date.cc.

References m_days, and m_ms_day.

◆ operator+()

JulianDate ns3::JulianDate::operator+ ( const Time &  t) const

operator + (positive time adjustment).

Parameters
ttime adjustment.
Returns
a JulianDate object with the adjustment incorporated.

Definition at line 268 of file julian-date.cc.

References DayToMs, m_days, m_ms_day, and m_time_scale.

◆ operator+=()

void ns3::JulianDate::operator+= ( const Time &  t)

operator += (positive time adjustment).

Parameters
ttime adjustment.

Definition at line 288 of file julian-date.cc.

◆ operator-() [1/2]

Time ns3::JulianDate::operator- ( const JulianDate jd) const

operator - (time between Julian dates).

Parameters
jdJulian days.
Returns
the time between both Julian dates.

Definition at line 326 of file julian-date.cc.

References m_days, and m_ms_day.

◆ operator-() [2/2]

JulianDate ns3::JulianDate::operator- ( const Time &  t) const

operator - (negative time adjustment).

Parameters
ttime adjustment.
Returns
a JulianDate object with the adjustment incorporated.

Definition at line 294 of file julian-date.cc.

References DayToMs, m_days, m_ms_day, and m_time_scale.

◆ operator-=()

void ns3::JulianDate::operator-= ( const Time &  t)

operator -= (negative time adjustment).

Parameters
ttime adjustment.

Definition at line 320 of file julian-date.cc.

◆ operator<()

bool ns3::JulianDate::operator< ( const JulianDate jd) const

operator < (compare Julian dates).

Parameters
jdJulian days.
Returns
a boolean to indicate if the Julian date is prior.

Definition at line 334 of file julian-date.cc.

References m_days, and m_ms_day.

◆ operator<=()

bool ns3::JulianDate::operator<= ( const JulianDate jd) const

operator <= (compare Julian dates).

Parameters
jdJulian days.
Returns
a boolean to indicate if the Julian date is prior or equal.

Definition at line 343 of file julian-date.cc.

References m_days, and m_ms_day.

◆ operator==()

bool ns3::JulianDate::operator== ( const JulianDate jd) const

operator == (compare Julian dates).

Parameters
jdJulian days.
Returns
a boolean to indicate if the Julian date is equal.

Definition at line 371 of file julian-date.cc.

References m_days, and m_ms_day.

◆ operator>()

bool ns3::JulianDate::operator> ( const JulianDate jd) const

operator > (compare Julian dates).

Parameters
jdJulian days.
Returns
a boolean to indicate if the Julian date is later.

Definition at line 353 of file julian-date.cc.

References m_days, and m_ms_day.

◆ operator>=()

bool ns3::JulianDate::operator>= ( const JulianDate jd) const

operator >= (compare Julian dates).

Parameters
jdJulian days.
Returns
a boolean to indicate if the Julian date is equal or later.

Definition at line 362 of file julian-date.cc.

References m_days, and m_ms_day.

◆ SetDate() [1/3]

void ns3::JulianDate::SetDate ( const std::string &  date,
TimeSystem  ts = DateTime::UTC 
)

Set Julian days using time in Gregorian calendar date.

Parameters
dateGregorian calendar date.
tsTime system of the date (UTC, UT1, TAI, TT or GPST).

Definition at line 234 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.

+ Here is the call graph for this function:

◆ SetDate() [2/3]

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.

Parameters
jdThe Julian days.

Definition at line 214 of file julian-date.cc.

References DayToMs, m_days, m_ms_day, m_time_scale, PosixEpoch, and ns3::DateTime::UTC.

Referenced by JulianDate().

+ Here is the caller graph for this function:

◆ SetDate() [3/3]

void ns3::JulianDate::SetDate ( uint32_t  days,
uint32_t  ms_day 
)

Set Julian days using the time since Unix/POSIX epoch.

Parameters
daysFull days since Unix/POSIX epoch (1 January 1970, 0h).
ms_dayMilliseconds of the day (since midnight).

Definition at line 225 of file julian-date.cc.

References m_days, m_ms_day, m_time_scale, and ns3::DateTime::POSIX.

◆ TaiMinusUtc()

Time ns3::JulianDate::TaiMinusUtc ( uint32_t  daysInPosix)
staticprivate

The difference between TAI and UTC time systems.

Parameters
daysInPosixFull days since Unix/POSIX epoch.
Returns
the difference between TAI and UTC (number of leap seconds).

Definition at line 409 of file julian-date.cc.

References ns3::IersData::BaseLeapSeconds, and ns3::IersData::LeapSeconds.

Referenced by OffsetFromUtc(), and OffsetToUtc().

+ Here is the caller graph for this function:

◆ ToString() [1/2]

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.

Returns
a string representing the Gregorian calendar date in time system ts.

Definition at line 147 of file julian-date.cc.

References m_time_scale, and ToString().

+ Here is the call graph for this function:

◆ ToString() [2/2]

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.

Returns
a string representing the date in the Gregorian calendar.

Definition at line 133 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const JulianDate jd 
)
friend

operator << (print as GregorianDate).

Print the textual representation (Gregorian calendar date) using the time system specified upon creation or setting.

Parameters
osOutput stream object.
jdJulian date object.
Returns
the output stream.

Definition at line 388 of file julian-date.cc.

Member Data Documentation

◆ DayToMs

const uint32_t ns3::JulianDate::DayToMs = HourToMs * 24
static

milliseconds in a day

millisecs in a day

Definition at line 90 of file julian-date.h.

Referenced by GetDouble(), GetOmegaEarth(), operator+(), operator-(), and SetDate().

◆ HourToMs

const uint32_t ns3::JulianDate::HourToMs = 3600000
static

milliseconds in an hour

millisecs in an hour

Definition at line 89 of file julian-date.h.

◆ J2000Epoch

const uint32_t ns3::JulianDate::J2000Epoch = 2451545
static

1 Jan 2000, 12h

Definition at line 87 of file julian-date.h.

◆ m_days

◆ m_ms_day

uint32_t ns3::JulianDate::m_ms_day
private

◆ m_time_scale

TimeSystem ns3::JulianDate::m_time_scale
private

external time system.

Definition at line 372 of file julian-date.h.

Referenced by JulianDate(), OffsetFromUtc(), OffsetToUtc(), operator+(), operator-(), SetDate(), and ToString().

◆ MaxYear

const uint32_t ns3::JulianDate::MaxYear = 2099
static

Maximum year supported.

maximum year

Definition at line 85 of file julian-date.h.

Referenced by SetDate().

◆ MinYear

const uint32_t ns3::JulianDate::MinYear = 1992
static

Minimum year supported.

IERS data since.

Definition at line 84 of file julian-date.h.

Referenced by JulianDate(), GregorianDate(), and SetDate().

◆ Posix1992

const uint32_t ns3::JulianDate::Posix1992 = 8035
static

1 Jan 1992 (POSIX days)

1 Jan 1992 (Unix days)

Definition at line 88 of file julian-date.h.

Referenced by Dut1(), GetOmegaEarth(), GetPolarMotion(), and GregorianDate().

◆ PosixEpoch

const double ns3::JulianDate::PosixEpoch = 2440587.5
static

1 Jan 1970, 0h

Definition at line 86 of file julian-date.h.

Referenced by GetDouble(), and SetDate().

◆ PosixYear

const uint32_t ns3::JulianDate::PosixYear = 1970
static

POSIX/Unix epoch year.

POSIX epoch year.

Definition at line 83 of file julian-date.h.

Referenced by JulianDate().

◆ TaiToGps

const Time ns3::JulianDate::TaiToGps = MilliSeconds(19000)
static

offset from TAI to GPST

TAI - GPST (in ms)

Definition at line 92 of file julian-date.h.

Referenced by OffsetFromUtc(), and OffsetToUtc().

◆ TtToTai

const Time ns3::JulianDate::TtToTai = MilliSeconds(32184)
static

offset from TT to TAI

TT - TAI (in ms)

Definition at line 91 of file julian-date.h.

Referenced by OffsetFromUtc(), and OffsetToUtc().


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