Skip to content

Commit

Permalink
Add Timestamp.get_time
Browse files Browse the repository at this point in the history
  • Loading branch information
JEnoch committed Sep 18, 2023
1 parent 72867fa commit 36256f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ impl _Timestamp {
}
}
#[getter]
pub fn get_time(&self) -> PyResult<u64> {
Ok(self.0.get_time().0)
}
#[getter]
pub fn seconds_since_unix_epoch(&self) -> PyResult<f64> {
Ok(self.0.get_time().as_secs_f64())
}
Expand Down
6 changes: 6 additions & 0 deletions zenoh/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ 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.
Expand Down

0 comments on commit 36256f3

Please sign in to comment.