pub struct Duration {
pub parsed_int: bool,
/* private fields */
}
rolling_window_by
only.Fields§
§parsed_int: bool
Implementations§
Source§impl Duration
impl Duration
Sourcepub fn parse(duration: &str) -> Duration
pub fn parse(duration: &str) -> Duration
Parse a string into a Duration
Strings are composed of a sequence of number-unit pairs, such as 5d
(5 days). A string may begin with a minus
sign, in which case it is interpreted as a negative duration. Some examples:
"1y"
: 1 year"-1w2d"
: negative 1 week, 2 days (i.e. -9 days)"3d12h4m25s"
: 3 days, 12 hours, 4 minutes, and 25 seconds
Aside from a leading minus sign, strings may not contain any characters other than numbers and letters (including whitespace).
The available units, in ascending order of magnitude, are as follows:
ns
: nanosecondus
: microsecondms
: milliseconds
: secondm
: minuteh
: hourd
: dayw
: weekmo
: calendar monthq
: calendar quartery
: calendar yeari
: index value (only for {Int32, Int64} dtypes)
By “calendar day”, we mean the corresponding time on the next day (which may not be 24 hours, depending on daylight savings). Similarly for “calendar week”, “calendar month”, “calendar quarter”, and “calendar year”.
§Panics
If the given str is invalid for any reason.
pub fn try_parse(duration: &str) -> Result<Duration, PolarsError>
pub fn try_parse_interval(interval: &str) -> Result<Duration, PolarsError>
pub fn months_only(&self) -> bool
pub fn months(&self) -> i64
pub fn weeks_only(&self) -> bool
pub fn weeks(&self) -> i64
pub fn days_only(&self) -> bool
pub fn days(&self) -> i64
Sourcepub fn is_full_days(&self) -> bool
pub fn is_full_days(&self) -> bool
Returns whether the duration consists of full days.
Note that 24 hours is not considered a full day due to possible daylight savings time transitions.
pub fn is_constant_duration(&self, time_zone: Option<&str>) -> bool
Sourcepub fn nanoseconds(&self) -> i64
pub fn nanoseconds(&self) -> i64
Returns the nanoseconds from the Duration
without the weeks or months part.
pub fn truncate_impl<F, G, J>( &self, t: i64, tz: Option<&Tz>, nsecs_to_unit: F, timestamp_to_datetime: G, datetime_to_timestamp: J, ) -> Result<i64, PolarsError>
pub fn truncate_ns(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn truncate_us(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn truncate_ms(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn add_ns(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn add_us(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
pub fn add_ms(&self, t: i64, tz: Option<&Tz>) -> Result<i64, PolarsError>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Duration
impl<'de> Deserialize<'de> for Duration
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Duration, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Duration, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Duration
impl Ord for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
Source§impl Serialize for Duration
impl Serialize for Duration
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Duration
impl Eq for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnwindSafe for Duration
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
]. Read more