Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wander committed Mar 13, 2024
1 parent 889dbca commit ee57299
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions gostd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "gostd"
license = "MIT"
version = "0.3.12"
version = "0.3.13"
edition = "2018"
authors = ["wandercn<[email protected]>"]
description = "gostd is the go standard library implementation in rust. gostd 是Go标准库的rust实现"
Expand All @@ -22,7 +22,7 @@ webpki-roots = "0.22.1"
rustls = "0.20.2"
gostd_derive = "0.0.3"
gostd_builtin = { version = "=1.0.4", optional = false, path = "../builtin" }
gostd_time = { version = "=1.0.6", optional = false, path = "../time" }
gostd_time = { version = "=1.0.7", optional = false, path = "../time" }
rand = "0.8.5"
log = "0.4"
lazy_static = "1.4.0"
2 changes: 1 addition & 1 deletion time/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "gostd_time"
license = "MIT"
version = "1.0.6"
version = "1.0.7"
edition = "2018"
authors = ["wandercn<[email protected]>"]
description = "Package time provides functionality for measuring and displaying time. time包提供了时间的显示和测量用的函数。日历的计算采用的是公历。"
Expand Down
24 changes: 24 additions & 0 deletions time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,30 @@ pub fn Unix(sec: int64, nsec: int64) -> Time {
/// <summary class="docblock">zh-cn</summary>
/// UnixMilli返回与给定的Unix时间相对应的本地时间,自1970年1月1日UTC以来的毫秒数。
/// </details>
///
/// # Example
/// ```
/// use gostd_time as time;
///
/// let timestamp_millis = 1571893634109_i64;
/// let t = time::UnixMilli(timestamp_millis);
/// println!("{}",t.Unix()); // seconds since 1970
/// println!("{}",t.UnixNano()); // nanoseconds since 1970
/// println!("{}", t.Format(time::RFC3339Nano));
/// assert_eq!(1571893634,t.Unix());
/// assert_eq!(1571893634109,t.UnixMilli());
/// assert_eq!(1571893634109000000,t.UnixNano());
/// assert_eq!("2019-10-24T05:07:14.109Z",t.Format(time::RFC3339Nano));
///
///
/// ```
/// ## Output:
///
/// ```text
/// 1571893634
/// 1571893634109000000
/// 2019-10-24T05:07:14.109Z
/// ```
pub fn UnixMilli(msec: int64) -> Time {
Unix(msec / 1000, (msec % 1000) * 1000_000)
}
Expand Down

0 comments on commit ee57299

Please sign in to comment.