rstime
English
A simple Rust time library with timestamp retrieval and UTC+8 datetime conversion.
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
Usage
use timestamp;
use time;
API
timestamp::new() -> timestamp— Creates a default timestamp instance.timestamp::get_timestamp(self) -> Self— Fills the instance with current UNIX timestamp in seconds, microseconds, and nanoseconds.time::new() -> time— Creates a default time instance.time::set_timezone(self, hours: i32) -> Self— Sets the timezone offset in hours.time::get_time(self) -> Self— Converts current timestamp to year/month/day/hour/minute/second with the configured timezone.time::is_leap_year(&self) -> bool— Checks if the stored year is a leap year.
License
MIT
中文
一个简单的 Rust 时间处理库,提供时间戳获取和 UTC+8 日期时间转换功能。
安装
在 Cargo.toml 中添加:
[]
= "0.1.0"
使用
use timestamp;
use time;
API
timestamp::new() -> timestamp— 创建默认时间戳实例。timestamp::get_timestamp(self) -> Self— 用当前 UNIX 时间戳(秒、微秒、纳秒)填充实例。time::new() -> time— 创建默认时间实例。time::set_timezone(self, hours: i32) -> Self— 设置时区偏移量,单位为小时。time::get_time(self) -> Self— 将当前时间戳按配置的时区转换为年/月/日/时/分/秒。time::is_leap_year(&self) -> bool— 判断当前存储的年份是否为闰年。
许可协议
MIT