| Crates.io | simple-ntp |
| lib.rs | simple-ntp |
| version | 0.1.1 |
| created_at | 2023-06-03 17:45:42.799197+00 |
| updated_at | 2023-06-03 18:02:17.418942+00 |
| description | Library to retrieve Unix timestamps using SNTP requests |
| homepage | |
| repository | https://github.com/llklkl/simple-ntp |
| max_upload_size | |
| id | 881780 |
| size | 11,977 |
Library to retrieve Unix timestamps using SNTP requests.
only for practice.
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);
}
MIT license