跳到主要内容

UnixTime

搜索

结构体 UnixTime 

Source
pub struct UnixTime(/* private fields */);
展开描述

一个时间戳,记录自 Unix 纪元以来的非闰秒数。

Unix 纪元定义为 1970 年 1 月 1 日 00:00:00 UTC。

实现§

Source§

impl UnixTime

Source

pub fn now() -> Self

当前时间,表示为一个 UnixTime

Source

pub const fn since_unix_epoch(duration: Duration) -> Self

将自 1970 年起经过的一个 Duration 转换为一个 UnixTime

duration 必须是相对于 Unix 纪元而言的。

Source

pub const fn as_secs(&self) -> u64

自 Unix 纪元以来的秒数

trait 实现§

Source§

impl Clone for UnixTime

Source§

fn clone(&self) -> UnixTime

返回该值的一个副本。更多信息
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 更多信息
Source§

impl Debug for UnixTime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

使用给定的格式化器格式化该值。更多信息
Source§

impl Hash for UnixTime

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

将该值送入给定的 Hasher 中。更多信息
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. 更多信息
Source§

impl Ord for UnixTime

Source§

fn cmp(&self, other: &UnixTime) -> Ordering

该方法返回 selfother 之间的 Ordering更多信息
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. 更多信息
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. 更多信息
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. 更多信息
Source§

impl PartialEq for UnixTime

Source§

fn eq(&self, other: &UnixTime) -> bool

测试 selfother 值是否相等,供 == 使用。
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

测试 != 运算符。默认实现几乎总是够用,除非有非常充分的理由,否则不应被覆盖。
Source§

impl PartialOrd for UnixTime

Source§

fn partial_cmp(&self, other: &UnixTime) -> Option<Ordering>

selfother 之间存在某种顺序,该方法返回相应的顺序。更多信息
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

测试小于(针对 selfother),供 < 运算符使用。 更多信息
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. 更多信息
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. 更多信息
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. 更多信息
Source§

impl Copy for UnixTime

Source§

impl Eq for UnixTime

Source§

impl StructuralPartialEq for UnixTime

自动 trait 实现§

blanket 实现§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. 更多信息
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 更多信息
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 更多信息
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

原样返回参数。

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

调用 U::from(self)

即此转换的实际行为取决于 From<T> for U 的实现。

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

获得所有权后的类型。
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. 更多信息
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 更多信息
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

转换出错时返回的类型。
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

执行转换。
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

转换出错时返回的类型。
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

执行转换。