45 : m_secs(0), m_subns(0) {}
49 constexpr
explicit Time(s64 subnanoseconds)
50 : m_secs (satcat5::util::divide(subnanoseconds,
SUBNS_PER_SEC))
51 , m_subns(satcat5::util::modulo(subnanoseconds,
SUBNS_PER_SEC)) {}
55 : m_secs(other.m_secs), m_subns(other.m_subns) {}
59 Time(u64 seconds, u32 nanoseconds, u16 subnanoseconds = 0);
71 {
return (u64)m_subns;}
Abstract API for reading byte-streams and packets.
Abstract API for writing byte-streams and packets.
Internal buffer used by the Log class.
High-precision timestamp for use with PTP / IEEE1588.
s64 delta_subns() const
Convert time-differences to the designated unit.
satcat5::ptp::Time operator=(const satcat5::ptp::Time &other)
Standard arithmetic operations.
bool operator!=(const satcat5::ptp::Time &other) const
Standard comparison operators.
constexpr Time(const Time &other)
Copy constructor.
bool operator<=(const satcat5::ptp::Time &other) const
Standard comparison operators.
s64 delta_nsec() const
Convert time-differences to the designated unit.
void operator*=(unsigned scale)
Scalar multiply and divide are used for weighted averaging.
bool read_from(satcat5::io::Readable *src)
Read the standard 10-byte timestamp from a PTP message (e.g., originTimestamp: u48 seconds + u32 nano...
u32 field_nsec() const
Read the "nanoseconds" field, rounding down.
s64 field_secs() const
Read the "seconds" field without intermediate rounding.
satcat5::ptp::Time operator+(const satcat5::ptp::Time &other) const
Standard arithmetic operations.
bool operator>=(const satcat5::ptp::Time &other) const
Standard comparison operators.
satcat5::ptp::Time abs() const
Standard arithmetic operations.
void log_to(satcat5::log::LogBuffer &wr) const
User-readable format for logging.
u64 field_subns() const
Read the raw "subnanoseconds" field.
bool operator>(const satcat5::ptp::Time &other) const
Standard comparison operators.
u32 round_nsec() const
Return "nanoseconds" field after rounding to the nearest nanosecond.
satcat5::ptp::Time operator/(unsigned scale) const
Scalar multiply and divide are used for weighted averaging.
void operator/=(unsigned scale)
Scalar multiply and divide are used for weighted averaging.
satcat5::ptp::Time operator-() const
Standard arithmetic operations.
s64 delta_usec() const
Convert time-differences to the designated unit.
constexpr Time(s64 subnanoseconds)
Single argument constructor is scaled in subnanoseconds.
s64 round_secs() const
Return "seconds" field after rounding to the nearest nanosecond.
u64 correction() const
Get the correctionField value in subnanoseconds.
s64 to_datetime() const
Convert to SatCat5 date/time.
void operator+=(const satcat5::ptp::Time &other)
Standard arithmetic operations.
void write_to(satcat5::io::Writeable *dst) const
Read or write the 10-byte timestamp from a PTP message.
satcat5::ptp::Time operator*(unsigned scale) const
Scalar multiply and divide are used for weighted averaging.
constexpr Time()
Default constructor.
void operator-=(const satcat5::ptp::Time &other)
Standard arithmetic operations.
s64 delta_msec() const
Convert time-differences to the designated unit.
bool operator==(const satcat5::ptp::Time &other) const
Standard comparison operators.
bool operator<(const satcat5::ptp::Time &other) const
Standard comparison operators.
constexpr satcat5::ptp::Time ONE_MILLISECOND(SUBNS_PER_MSEC)
Common time-related constants.
constexpr s64 SUBNS_PER_MSEC
Define commonly used scaling factors.
constexpr s64 SUBNS_PER_SEC
Define commonly used scaling factors.
constexpr s64 USEC_PER_SEC
Define commonly used scaling factors.
constexpr satcat5::ptp::Time ONE_HOUR(SUBNS_PER_SEC *3600)
Common time-related constants.
constexpr satcat5::ptp::Time ONE_SECOND(SUBNS_PER_SEC)
Common time-related constants.
constexpr s64 NSEC_PER_MSEC
Define commonly used scaling factors.
constexpr s64 NSEC_PER_SEC
Define commonly used scaling factors.
constexpr satcat5::ptp::Time ONE_MINUTE(SUBNS_PER_SEC *60)
Common time-related constants.
constexpr s64 SUBNS_PER_NSEC
Define commonly used scaling factors.
constexpr satcat5::ptp::Time ONE_DAY(SUBNS_PER_SEC *3600 *24)
Common time-related constants.
constexpr s64 NSEC_PER_USEC
Define commonly used scaling factors.
constexpr satcat5::ptp::Time TIME_ZERO(0LL)
Common time-related constants.
constexpr satcat5::ptp::Time ONE_NANOSECOND(SUBNS_PER_NSEC)
Common time-related constants.
constexpr s64 MSEC_PER_SEC
Define commonly used scaling factors.
constexpr s64 SUBNS_PER_USEC
Define commonly used scaling factors.
constexpr satcat5::ptp::Time ONE_MICROSECOND(SUBNS_PER_USEC)
Common time-related constants.
Basic type aliases and prototypes used throughout SatCat5.
Miscellaneous mathematical utility functions.