diff --git a/Cargo.lock b/Cargo.lock index 25cc7254..7c778d22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2251,11 +2251,10 @@ checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "uhlc" -version = "0.6.0" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af1438496174a601a35fb41bf9bc408e47384b1df52ddc1252e75ef0ab811322" +checksum = "d1eadef1fa26cbbae1276c46781e8f4d888bdda434779c18ae6c2a0e69991885" dependencies = [ - "hex", "humantime", "lazy_static", "log", diff --git a/src/value.rs b/src/value.rs index 0432412f..ceb8d727 100644 --- a/src/value.rs +++ b/src/value.rs @@ -194,16 +194,12 @@ impl _Timestamp { } } #[getter] - pub fn seconds_since_unix_epoch(&self) -> PyResult { - match self - .0 - .get_time() - .to_system_time() - .duration_since(std::time::UNIX_EPOCH) - { - Ok(o) => Ok(o.as_secs_f64()), - Err(e) => Err(e.to_pyerr()), - } + pub fn get_time(&self) -> u64 { + self.0.get_time().0 + } + #[getter] + pub fn seconds_since_unix_epoch(&self) -> f64 { + self.0.get_time().as_secs_f64() } } diff --git a/zenoh/value.py b/zenoh/value.py index 5c33685f..6446f52a 100644 --- a/zenoh/value.py +++ b/zenoh/value.py @@ -114,11 +114,18 @@ class Timestamp(_Timestamp): def _upgrade_(this: _Timestamp) -> 'Timestamp': return _Timestamp.__new__(Timestamp, this) @property + def get_time(self) -> int: + """ + Returns the time part, as generated by the Zenoh HLC in NTP64 format (See https://datatracker.ietf.org/doc/html/rfc5905#section-6). + """ + return super().time + @property def seconds_since_unix_epoch(self) -> float: """ Returns the number of seconds since the Unix Epoch. - You shouldn't use this for comparison though, and rely on comparison operators between members of this class. + Considering the large number of seconds since the Unix Epoch, the precision of the resulting f64 is in the order of microseconds. + Therefore, it should not be used for comparison. Directly comparing Timestamp objects is preferable. """ return super().seconds_since_unix_epoch