Skip to content

Instantly share code, notes, and snippets.

@tupshin
Created February 11, 2020 19:23
Show Gist options
  • Save tupshin/1cc506a99e9189ed1b604461619d12ce to your computer and use it in GitHub Desktop.
Save tupshin/1cc506a99e9189ed1b604461619d12ce to your computer and use it in GitHub Desktop.
use openfmb_ops_protobuf::openfmb::commonmodule;
fn get_current_datetime() -> Timestamp {
let t = Utc::now();
let tq = commonmodule::TimeQuality {
clock_failure: false,
clock_not_synchronized: false,
leap_seconds_known: true,
time_accuracy: commonmodule::TimeAccuracyKind::Unspecified as i32,
};
commonmodule::Timestamp {
fraction: (t.timestamp_subsec_nanos() as f64 / ((1000000000 as f64) * (2u32.pow(32) as f64) as f64)) as u32,
seconds: t.timestamp() as u64,
tq: Some(tq),
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment