Enum astrolabe::DateTimeUnit
source · [−]pub enum DateTimeUnit {
Year,
Month,
Day,
Hour,
Min,
Sec,
Centis,
Millis,
Micros,
Nanos,
}Expand description
Date and time units for functions like DateTime::get or DateTime::apply.
Variants
Year
Month
Note: When used in the DateTime::apply function, this unit adds or removes calendar months, not 30 days.
let date_time = DateTime::from_ymd(1970, 1, 31).unwrap();
assert_eq!("1970-02-28", date_time.apply(1, DateTimeUnit::Month).unwrap().format("yyyy-MM-dd"));
assert_eq!("1970-03-31", date_time.apply(2, DateTimeUnit::Month).unwrap().format("yyyy-MM-dd"));
assert_eq!("1970-04-30", date_time.apply(3, DateTimeUnit::Month).unwrap().format("yyyy-MM-dd"));Day
Hour
Min
Sec
Centis
Millis
Micros
Nanos
Trait Implementations
sourceimpl Clone for DateTimeUnit
impl Clone for DateTimeUnit
sourcefn clone(&self) -> DateTimeUnit
fn clone(&self) -> DateTimeUnit
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for DateTimeUnit
impl Debug for DateTimeUnit
sourceimpl PartialEq<DateTimeUnit> for DateTimeUnit
impl PartialEq<DateTimeUnit> for DateTimeUnit
sourcefn eq(&self, other: &DateTimeUnit) -> bool
fn eq(&self, other: &DateTimeUnit) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
impl Eq for DateTimeUnit
impl StructuralEq for DateTimeUnit
impl StructuralPartialEq for DateTimeUnit
Auto Trait Implementations
impl RefUnwindSafe for DateTimeUnit
impl Send for DateTimeUnit
impl Sync for DateTimeUnit
impl Unpin for DateTimeUnit
impl UnwindSafe for DateTimeUnit
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more