pub struct Duration {
pub year: f32,
pub month: f32,
pub day: f32,
pub hour: f32,
pub minute: f32,
pub second: f32,
}
Fields§
§year: f32
§month: f32
§day: f32
§hour: f32
§minute: f32
§second: f32
Implementations§
Source§impl Duration
impl Duration
Sourcepub fn to_chrono(&self) -> Option<ChronoDuration>
pub fn to_chrono(&self) -> Option<ChronoDuration>
Convert Duration
to chrono::Duration
.
This method will return None
is Duration
contains
year
or month
.
Sourcepub fn to_chrono_at_datetime<Tz: TimeZone>(
&self,
at: DateTime<Tz>,
) -> ChronoDuration
pub fn to_chrono_at_datetime<Tz: TimeZone>( &self, at: DateTime<Tz>, ) -> ChronoDuration
Convert Duration
to chrono::Duration
at given datetime.
Source§impl Duration
impl Duration
Sourcepub fn new(
year: f32,
month: f32,
day: f32,
hour: f32,
minute: f32,
second: f32,
) -> Self
pub fn new( year: f32, month: f32, day: f32, hour: f32, minute: f32, second: f32, ) -> Self
Create a new duration
Sourcepub fn num_years(&self) -> Option<f32>
pub fn num_years(&self) -> Option<f32>
Return number of years in the duration
This method will return None
is Duration
contains
second
, minute
or hour
.
Sourcepub fn num_months(&self) -> Option<f32>
pub fn num_months(&self) -> Option<f32>
Return number of months in the duration
This method will return None
is Duration
contains
second
, minute
or hour
.
Sourcepub fn num_weeks(&self) -> Option<f32>
pub fn num_weeks(&self) -> Option<f32>
Return number of weeks in the duration
This method will return None
is Duration
contains
year
or month
.
Sourcepub fn num_days(&self) -> Option<f32>
pub fn num_days(&self) -> Option<f32>
Return number of days in the duration
This method will return None
is Duration
contains
year
or month
.
Sourcepub fn num_hours(&self) -> Option<f32>
pub fn num_hours(&self) -> Option<f32>
Return number of hours in the duration
This method will return None
is Duration
contains
year
or month
.
Sourcepub fn num_minutes(&self) -> Option<f32>
pub fn num_minutes(&self) -> Option<f32>
Return number of minutes in the duration
This method will return None
is Duration
contains
year
or month
.
Sourcepub fn num_seconds(&self) -> Option<f32>
pub fn num_seconds(&self) -> Option<f32>
Return number of seconds in the duration
This method will return None
is Duration
contains
year
or month
.
Sourcepub fn to_std(&self) -> Option<StdDuration>
pub fn to_std(&self) -> Option<StdDuration>
Convert duration to std::time::Duration
.
This method will return None
is Duration
contains
year
or month
.
See to know how to convert a Duration
contains
year
or month
.