31#include "ns3/assert.h"
32#include "ns3/nstime.h"
141 std::ostringstream oss;
144 oss << std::setfill(
'0');
145 oss << std::setw(4) << dt.
year <<
"-" << std::setw(2) << dt.
month <<
"-" << std::setw(2)
146 << dt.
day <<
" " << std::setw(2) << dt.
hours <<
":" << std::setw(2) << dt.
minutes <<
":"
162std::pair<double, double>
171 return std::make_pair(v[pos].xp, v[pos].yp);
174 return std::make_pair(0, 0);
182 double lod = (pos < v.size() ? v[pos].lod : 0);
186 return 7.2921151467064e-5 * (1.0 - lod /
DayToMs);
227 m_days =
static_cast<uint32_t
>(jd);
247 NS_ASSERT_MSG(ts !=
DateTime::POSIX,
"POSIX/Unix time scale is not valid for dates.");
250 std::sscanf(date.c_str(),
251 "%04u%*c%02u%*c%02u %02u%*c%02u%*c%lf",
259 NS_ASSERT_MSG(dt.
year >=
MinYear,
"Complete EOP data is not available before that date!");
261 NS_ASSERT_MSG(dt.
year <=
MaxYear,
"Dates beyond 2099 are not supported!");
263 dt.
seconds =
static_cast<uint32_t
>(seconds);
268 static_cast<uint32_t
>(
PosixEpoch - 1721013.5);
281 if (t.IsStrictlyNegative())
283 return *
this - MilliSeconds(-t.GetMilliSeconds());
286 jd.
m_days =
static_cast<uint32_t
>(t.GetDays());
309 if (t.IsStrictlyNegative())
311 return *
this + MilliSeconds(-t.GetMilliSeconds());
314 jd.
m_days =
static_cast<uint32_t
>(t.GetDays());
431 return ((year & 0x03) == 0);
438 std::vector<uint32_t>::const_iterator it;
440 it = std::lower_bound(v.begin(), v.end(), daysInPosix);
451 return MilliSeconds(pos < v.size() ? v[pos].dut1 * 1000 : 0);
463 uint32_t month_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
464 uint32_t d = days -
Posix1992, days_of_year, leap_years;
465 Time t = MilliSeconds(ms_day);
469 dt.
year =
static_cast<uint32_t
>(d / 365.25) +
MinYear;
472 days_of_year = d - ((dt.
year -
MinYear) * 365 + leap_years);
480 for (uint32_t i = 0; i < 12; ++i)
482 if (days_of_year <= month_days[i])
489 days_of_year -= month_days[i];
492 dt.
day = days_of_year;
494 dt.
hours =
static_cast<uint32_t
>(t.GetHours());
495 t -= Hours(dt.
hours);
497 dt.
minutes =
static_cast<uint32_t
>(t.GetMinutes());
500 dt.
seconds =
static_cast<uint32_t
>(t.GetSeconds());
503 dt.
millisecs =
static_cast<uint32_t
>(t.GetMilliSeconds());
518 Time offset = MilliSeconds(0);
523 offset =
Dut1(daysInPosix);
553 return MilliSeconds(0);
560 if (ms_day < (offset + tai_utc).GetMilliSeconds())
568 offset =
Dut1(daysInPosix);
584 return MilliSeconds(-offset.GetMilliSeconds());
static const std::vector< uint32_t > LeapSeconds
static const std::vector< EopParameters > EopValues
static const uint32_t BaseLeapSeconds
Class to handle Julian days and provide respective Earth Orientation Parameters (EOP).
static bool IsLeapYear(uint32_t year)
Check if it is a leap year.
JulianDate(void)
Default constructor.
double GetGmst(void) const
Retrieve the Greenwich Mean Sidereal Time.
static const Time TaiToGps
offset from TAI to GPST
void SetDate(double jd)
Set the Julian days.
uint32_t m_days
full days since epoch.
double GetDouble(TimeSystem ts=DateTime::UTC) const
GetDouble Get the Julian days.
bool operator>(const JulianDate &jd) const
operator > (compare Julian dates).
bool operator==(const JulianDate &jd) const
operator == (compare Julian dates).
JulianDate operator-(const Time &t) const
operator - (negative time adjustment).
JulianDate operator+(const Time &t) const
operator + (positive time adjustment).
Time OffsetFromUtc(void) const
Returns the offset from UTC.
TimeSystem m_time_scale
external time system.
static const uint32_t PosixYear
POSIX/Unix epoch year.
static const uint32_t DayToMs
milliseconds in a day
static const uint32_t MinYear
Minimum year supported.
Time OffsetToUtc(void) const
Returns the offset to UTC.
static Time TaiMinusUtc(uint32_t daysInPosix)
The difference between TAI and UTC time systems.
static const Time TtToTai
offset from TT to TAI
static const double PosixEpoch
1 Jan 1970, 0h
uint32_t m_ms_day
milliseconds of the day.
static const uint32_t HourToMs
milliseconds in an hour
std::string ToString(void) const
Get the string representation of the Gregorian calendar date.
DateTime GetDateTime(void) const
Get the Gregorian calendar date in current time system.
bool operator<(const JulianDate &jd) const
operator < (compare Julian dates).
double GetOmegaEarth(void) const
Retrieve Earth's angular velocity.
bool operator!=(const JulianDate &jd) const
operator != (compare Julian dates).
static Time Dut1(uint32_t daysInPosix)
Retrieve the DUT1 (UT1 - UTC) value for a given day.
DateTime::TimeSystem TimeSystem
equivalent to C++11 using TimeSystem = DateTime::TimeSystem.
std::pair< double, double > GetPolarMotion(void) const
Retrieve the polar motion cofficients measured/predicted.
DateTime GregorianDate(void) const
Convert into Gregorian calendar.
bool operator<=(const JulianDate &jd) const
operator <= (compare Julian dates).
bool operator>=(const JulianDate &jd) const
operator >= (compare Julian dates).
void operator+=(const Time &t)
operator += (positive time adjustment).
static const uint32_t J2000Epoch
1 Jan 2000, 12h
void operator-=(const Time &t)
operator -= (negative time adjustment).
static const uint32_t Posix1992
1 Jan 1992 (POSIX days)
static const uint32_t MaxYear
Maximum year supported.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
std::ostream & operator<<(std::ostream &os, const GeoCoordinate &coordinate)
double gstime(double jdut1)
@ UTC
Coordinated Universal Time [French: Temps Universel Coordonné].
@ TAI
International Atomic Time [French: Temps Atomique International].
@ GPST
Global Positioning System (GPS) Time.