31 #include <ns3/assert.h>
32 #include <ns3/nstime.h>
135 std::ostringstream oss;
138 oss << std::setfill(
'0');
139 oss << std::setw(4) << dt.
year <<
"-" << std::setw(2) << dt.
month <<
"-" << std::setw(2)
140 << dt.
day <<
" " << std::setw(2) << dt.
hours <<
":" << std::setw(2) << dt.
minutes <<
":"
156 std::pair<double, double>
164 return std::make_pair(v[pos].xp, v[pos].yp);
166 return std::make_pair(0, 0);
174 double lod = (pos < v.size() ? v[pos].lod : 0);
178 return 7.2921151467064e-5 * (1.0 - lod /
DayToMs);
219 m_days =
static_cast<uint32_t
>(jd);
239 NS_ASSERT_MSG(ts !=
DateTime::POSIX,
"POSIX/Unix time scale is not valid for dates.");
242 std::sscanf(date.c_str(),
243 "%04d%*c%02d%*c%02d %02d%*c%02d%*c%lf",
251 NS_ASSERT_MSG(dt.
year >=
MinYear,
"Complete EOP data is not available before that date!");
253 NS_ASSERT_MSG(dt.
year <=
MaxYear,
"Dates beyond 2099 are not supported!");
255 dt.
seconds =
static_cast<uint32_t
>(seconds);
260 static_cast<uint32_t
>(
PosixEpoch - 1721013.5);
273 if (t.IsStrictlyNegative())
274 return *
this - MilliSeconds(-t.GetMilliSeconds());
276 jd.
m_days =
static_cast<uint32_t
>(t.GetDays());
299 if (t.IsStrictlyNegative())
300 return *
this + MilliSeconds(-t.GetMilliSeconds());
302 jd.
m_days =
static_cast<uint32_t
>(t.GetDays());
405 return ((year & 0x03) == 0);
412 std::vector<uint32_t>::const_iterator it;
414 it = std::lower_bound(v.begin(), v.end(), daysInPosix);
425 return MilliSeconds(pos < v.size() ? v[pos].dut1 * 1000 : 0);
437 uint32_t month_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
438 uint32_t d = days -
Posix1992, days_of_year, leap_years;
439 Time t = MilliSeconds(ms_day);
443 dt.
year =
static_cast<uint32_t
>(d / 365.25) +
MinYear;
446 days_of_year = d - ((dt.
year -
MinYear) * 365 + leap_years);
452 for (uint32_t i = 0; i < 12; ++i)
454 if (days_of_year <= month_days[i])
461 days_of_year -= month_days[i];
464 dt.
day = days_of_year;
466 dt.
hours =
static_cast<uint32_t
>(t.GetHours());
467 t -= Hours(dt.
hours);
469 dt.
minutes =
static_cast<uint32_t
>(t.GetMinutes());
472 dt.
seconds =
static_cast<uint32_t
>(t.GetSeconds());
475 dt.
millisecs =
static_cast<uint32_t
>(t.GetMilliSeconds());
490 Time offset = MilliSeconds(0);
495 offset =
Dut1(daysInPosix);
524 return MilliSeconds(0);
530 if (ms_day < (offset + tai_utc).GetMilliSeconds())
536 offset =
Dut1(daysInPosix);
552 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.
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.