pub struct TimeUtils;
Expand description
时间工具
Implementations§
Source§impl TimeUtils
impl TimeUtils
Sourcepub fn current_timestamp() -> i64
pub fn current_timestamp() -> i64
获取当前时间戳(秒)
Sourcepub fn current_timestamp_millis() -> i64
pub fn current_timestamp_millis() -> i64
获取当前时间戳(毫秒)
Sourcepub fn current_datetime_str() -> String
pub fn current_datetime_str() -> String
获取当前日期时间字符串
Sourcepub fn current_date_str() -> String
pub fn current_date_str() -> String
获取当前日期字符串
Sourcepub fn current_time_str() -> String
pub fn current_time_str() -> String
获取当前时间字符串
Sourcepub fn timestamp_to_datetime_str(timestamp: i64) -> String
pub fn timestamp_to_datetime_str(timestamp: i64) -> String
时间戳转日期时间字符串
Sourcepub fn datetime_str_to_timestamp(datetime_str: &str) -> Option<i64>
pub fn datetime_str_to_timestamp(datetime_str: &str) -> Option<i64>
日期时间字符串转时间戳
Sourcepub fn parse_datetime(
datetime_str: &str,
format: &str,
) -> Option<DateTime<Local>>
pub fn parse_datetime( datetime_str: &str, format: &str, ) -> Option<DateTime<Local>>
解析日期时间字符串
Sourcepub fn current_datetime() -> DateTime<Utc>
pub fn current_datetime() -> DateTime<Utc>
获取当前时间
Sourcepub fn serialize_optional_datetime<S>(
value: &Option<DateTime<Utc>>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
pub fn serialize_optional_datetime<S>(
value: &Option<DateTime<Utc>>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
序列化响应的时间格式
pub fn deserialize_optional_datetime<'de, D>(
deserializer: D,
) -> Result<Option<DateTime<Utc>>, D::Error>where
D: Deserializer<'de>,
Sourcepub fn format_duration(duration: Duration) -> String
pub fn format_duration(duration: Duration) -> String
格式化时间间隔
Auto Trait Implementations§
impl Freeze for TimeUtils
impl RefUnwindSafe for TimeUtils
impl Send for TimeUtils
impl Sync for TimeUtils
impl Unpin for TimeUtils
impl UnwindSafe for TimeUtils
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more