#ntp #client #time #lib

xntp

A ntp client lib for Rust

4 releases

0.1.3 Jan 10, 2023
0.1.2 Jan 10, 2023
0.1.1 Jan 10, 2023
0.1.0 Jan 10, 2023

#25 in #ntp

MIT/Apache

4KB
54 lines

xntp

this is a simple and small ntp time client

example

use xntp::NtpClient;
fn main(){
    let client = NtpClient::new();
    let res = client.request("ntp.aliyun.com");
    println!("{}", res.unix_time);
    println!("{}", res.format_time("%Y-%m-%d %H:%M:%S"));
}

lib.rs:

XNtp

xntp is a client of ntp to get net time and format

Example

use xntp::NtpClient;
fn main(){
    let client = NtpClient::new();
    let res = client.request("ntp.aliyun.com");
    println!("{}", res.unix_time);
    println!("{}", res.format_time("%Y-%m-%d %H:%M:%S"));
}

Dependencies

~1.5MB
~20K SLoC