pub struct Duration {
pub parsed_int: bool,
/* private fields */
}
Fields§
§parsed_int: bool
Implementations§
Source§impl Duration
impl Duration
Sourcepub fn parse(duration: &str) -> Self
pub fn parse(duration: &str) -> Self
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) -> PolarsResult<Self>
pub fn try_parse_interval(interval: &str) -> PolarsResult<Self>
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, ) -> PolarsResult<i64>
pub fn truncate_ns(&self, t: i64, tz: Option<&Tz>) -> PolarsResult<i64>
pub fn truncate_us(&self, t: i64, tz: Option<&Tz>) -> PolarsResult<i64>
pub fn truncate_ms(&self, t: i64, tz: Option<&Tz>) -> PolarsResult<i64>
pub fn add_ns(&self, t: i64, tz: Option<&Tz>) -> PolarsResult<i64>
pub fn add_us(&self, t: i64, tz: Option<&Tz>) -> PolarsResult<i64>
pub fn add_ms(&self, t: i64, tz: Option<&Tz>) -> PolarsResult<i64>
Trait Implementations§
Source§impl Ord for Duration
impl Ord for Duration
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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.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