Skip to main content

to_timestamp

Function to_timestamp 

pub fn to_timestamp(n: UnixNanos) -> Timestamp
Expand description

Unix nanoseconds -> protobuf timestamp. Negative values give seconds < 0 and nanos >= 0, the protobuf way.

§Examples

use brokapi_core::UnixNanos;
use brokapi_finam::util::{to_timestamp, ts_nanos};

let t = to_timestamp(UnixNanos::from_nanos(1_700_000_000_123_456_789));
assert_eq!((t.seconds, t.nanos), (1_700_000_000, 123_456_789));
assert_eq!(ts_nanos(&t).as_nanos(), 1_700_000_000_123_456_789);