DateUtil

Struct DateUtil 

Source
pub struct DateUtil {}

Implementations§

Source§

impl DateUtil

Source

pub fn get_end_of_year(input_datetime: NaiveDateTime) -> NaiveDateTime

获取结束年的时间

§参数
  • input_datetime: 输入日期时间

返回值: 结束年的时间

Source

pub fn get_end_of_month(input_datetime: NaiveDateTime) -> NaiveDateTime

获取结束月的时间

§参数
  • input_datetime: 输入日期时间

返回值: 结束月的时间

Source

pub fn get_end_of_week(input_datetime: NaiveDateTime) -> NaiveDateTime

获取结束周的时间

§参数
  • input_datetime: 输入日期时间

返回值: 结束周的时间

Source

pub fn get_start_of_year(input_datetime: NaiveDateTime) -> NaiveDateTime

获取开始年的时间

§参数
  • input_datetime: 输入日期时间

返回值: 开始年的时间

Source

pub fn get_start_of_month(input_datetime: NaiveDateTime) -> NaiveDateTime

获取开始月的时间

§参数
  • input_datetime: 输入日期时间

返回值: 开始月的时间

Source

pub fn get_start_of_week(input_datetime: NaiveDateTime) -> NaiveDateTime

获取开始周的时间

§参数
  • input_datetime: 输入日期时间

返回值: 开始周的时间

Source

pub fn get_start_of_day_for_day(input_date: NaiveDate) -> NaiveDateTime

获取一天中的起始时间

§参数
  • input_date: 输入日期(不包含时间部分)

返回值: 一天中的起始时间

Source

pub fn get_end_of_day_for_day(input_date: NaiveDate) -> NaiveDateTime

获取一天的结束时间

§参数
  • input_date: 输入日期(不包含时间部分)

返回值: 一天的结束时间

Source

pub fn get_start_of_day(input_datetime: NaiveDateTime) -> NaiveDateTime

获取一天的起始时间

§参数
  • input_datetime: 输入日期时间

返回值: 一天的起始时间

Source

pub fn get_end_of_day(input_datetime: NaiveDateTime) -> NaiveDateTime

获取一天的结束时间

§参数
  • input_datetime: 输入日期时间

返回值: 一天的结束时间

Source

pub fn manipulate_time( input_time: NaiveDateTime, step: i64, unit: TimeUnit, ) -> NaiveDateTime

对 NaiveDateTime 进行时间加减法

§参数
  • input_time: 输入时间
  • step: 步长,可以是正数或负数
  • unit: 时间单位,使用 TimeUnit 枚举表示

返回值: 计算后的时间

Source

pub fn parse_time( input: String, format_str: DateTimeFormat, ) -> Option<NaiveDateTime>

解析时间字符串

§参数
  • input: 待解析的时间字符串
  • format_str: 时间格式

返回值: 解析后的时间,以 NaiveDateTime 格式表示

Source

pub fn get_now_time_string(format_str: DateTimeFormat) -> String

获取当前时间

§参数
  • format_str: 目标格式

返回值: String 当前时间的字符串表示

Source

pub fn now() -> NaiveDateTime

Source

pub fn get_now_time_utc_string(format_str: DateTimeFormat) -> String

获取当前 UTC 时间

§参数
  • format_str: 目标格式

返回值: String 当前 UTC 时间的字符串表示

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V