simple-ntp 0.1.1

Library to retrieve Unix timestamps using SNTP requests
Documentation
  • Coverage
  • 35.71%
    5 out of 14 items documented2 out of 7 items with examples
  • Size
  • Source code size: 11.66 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.69 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • llklkl/simple-ntp
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • llklkl

simple-ntp

Library to retrieve Unix timestamps using SNTP requests.

only for practice.

example

use cargo add simple-ntp.

cargo add simple-ntp

example code:

use simple_ntp::sntp;

fn main() {
    let timestamp = sntp::unix_timestamp("ntp.aliyun.com").unwrap();
    println!("{:?}", timestamp);

    // use specified port
    let timestamp = sntp::unix_timestamp("ntp.aliyun.com:123").unwrap();
    println!("{:?}", timestamp);

    let delta = sntp::clock_offset_nanos("ntp.aliyun.com").unwrap();
    println!("{:?}", delta as f64 / 1e9);
}

license

MIT license