31 #include <ns3/assert.h>
32 #include <ns3/nstime.h>
139 std::ostringstream oss;
142 oss << std::setfill(
'0');
143 oss << std::setw(4) << dt.
year <<
"-" << std::setw(2) << dt.
month <<
"-" << std::setw(2)
144 << dt.
day <<
" " << std::setw(2) << dt.
hours <<
":" << std::setw(2) << dt.
minutes <<
":"
160 std::pair<double, double>
168 return std::make_pair(v[pos].xp, v[pos].yp);
170 return std::make_pair(0, 0);
178 double lod = (pos < v.size() ? v[pos].lod : 0);
182 return 7.2921151467064e-5 * (1.0 - lod /
DayToMs);
223 m_days =
static_cast<uint32_t
>(jd);
243 NS_ASSERT_MSG(ts !=
DateTime::POSIX,
"POSIX/Unix time scale is not valid for dates.");
246 std::sscanf(date.c_str(),
247 "%04u%*c%02u%*c%02u %02u%*c%02u%*c%lf",
255 NS_ASSERT_MSG(dt.
year >=
MinYear,
"Complete EOP data is not available before that date!");
257 NS_ASSERT_MSG(dt.
year <=
MaxYear,
"Dates beyond 2099 are not supported!");
259 dt.
seconds =
static_cast<uint32_t
>(seconds);
264 static_cast<uint32_t
>(
PosixEpoch - 1721013.5);
277 if (t.IsStrictlyNegative())
278 return *
this - MilliSeconds(-t.GetMilliSeconds());
280 jd.
m_days =
static_cast<uint32_t
>(t.GetDays());
303 if (t.IsStrictlyNegative())
304 return *
this + MilliSeconds(-t.GetMilliSeconds());
306 jd.
m_days =
static_cast<uint32_t
>(t.GetDays());
409 return ((year & 0x03) == 0);
416 std::vector<uint32_t>::const_iterator it;
418 it = std::lower_bound(v.begin(), v.end(), daysInPosix);
429 return MilliSeconds(pos < v.size() ? v[pos].dut1 * 1000 : 0);
441 uint32_t month_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
442 uint32_t d = days -
Posix1992, days_of_year, leap_years;
443 Time t = MilliSeconds(ms_day);
447 dt.
year =
static_cast<uint32_t
>(d / 365.25) +
MinYear;
450 days_of_year = d - ((dt.
year -
MinYear) * 365 + leap_years);
456 for (uint32_t i = 0; i < 12; ++i)
458 if (days_of_year <= month_days[i])
465 days_of_year -= month_days[i];
468 dt.
day = days_of_year;
470 dt.
hours =
static_cast<uint32_t
>(t.GetHours());
471 t -= Hours(dt.
hours);
473 dt.
minutes =
static_cast<uint32_t
>(t.GetMinutes());
476 dt.
seconds =
static_cast<uint32_t
>(t.GetSeconds());
479 dt.
millisecs =
static_cast<uint32_t
>(t.GetMilliSeconds());
494 Time offset = MilliSeconds(0);
499 offset =
Dut1(daysInPosix);
528 return MilliSeconds(0);
534 if (ms_day < (offset + tai_utc).GetMilliSeconds())
540 offset =
Dut1(daysInPosix);
556 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.