simple-ntp

Crates.iosimple-ntp
lib.rssimple-ntp
version0.1.1
sourcesrc
created_at2023-06-03 17:45:42.799197
updated_at2023-06-03 18:02:17.418942
descriptionLibrary to retrieve Unix timestamps using SNTP requests
homepage
repositoryhttps://github.com/llklkl/simple-ntp
max_upload_size
id881780
size11,977
(llklkl)

documentation

README

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

Commit count: 3

cargo fmt