#ntp #client #time #lib

xntp

Rust 的 ntp 客户端库

4 个版本

0.1.3 2023年1月10日
0.1.2 2023年1月10日
0.1.1 2023年1月10日
0.1.0 2023年1月10日

#24 in #ntp

MIT/Apache

4KB
54

xntp

这是一个简单小巧的 ntp 时间客户端

示例

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 是一个获取网络时间和格式的 ntp 客户端

示例

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"));
}

依赖项

~1.5MB
~20K SLoC