Struct timelog::date::Date

source ·
pub struct Date(_);
Expand description

Representation of a date in the local time zone.

Implementations§

source§

impl Date

source

pub fn new(year: i32, month: u32, day: u32) -> Result<Self>

Create a Date out of a year, month, and day, returning a Result.

Errors

If one of the parameters is outside the legal range for a date, returns an DateError::InvalidDate.

source

pub fn today() -> Self

Create a Date for today.

source

pub fn parse(datespec: &str) -> Result<Self>

Create a Date object from the supplied date specification.

Legal specifications include “today” and “yesterday”, the days of the week “sunday” through “saturday”, and a date in the form “YYYY-MM-DD”. The days of the week result in the date representing the previous instance of that day (last Monday for “monday”, etc.).

Errors

Return DateError::InvalidDaySpec if the supplied spec is not valid.

source§

impl Date

source

pub fn year(&self) -> i32

Return the year portion of the Date

source

pub fn month(&self) -> u32

Return the month portion of the Date

source

pub fn day(&self) -> u32

Return the day portion of the Date

source

pub fn weekday(&self) -> Weekday

Return the day of the week enum.

source

pub fn weekday_str(&self) -> &'static str

Return the day of the week as a string.

source§

impl Date

source

pub fn day_start(&self) -> DateTime

Create a DateTime object for the first second of the current Date

source

pub fn day_end(&self) -> DateTime

Create a DateTime object for the last second of the current Date

source

pub fn month_start(&self) -> Date

Create a Date object for the last day of the month.

source

pub fn month_end(&self) -> Date

Create a Date object for the last day of the month.

source

pub fn week_start(&self) -> Date

Create a Date object for the first day of the week.

source

pub fn week_end(&self) -> Date

Create a Date object for the last day of the week.

source

pub fn year_start(&self) -> Date

Create a Date object for the beginning of the year containing the date.

source

pub fn year_end(&self) -> Date

Create a Date object for the end of the year containing the date.

source

pub fn succ(&self) -> Date

Create a Date for the day after the current date.

source

pub fn pred(&self) -> Date

Create a Date for the day before the current date.

Trait Implementations§

source§

impl Clone for Date

source§

fn clone(&self) -> Date

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Date

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Date

source§

fn default() -> Date

The default Date is the current day.

source§

impl Display for Date

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Format a Date object in “YYYY-MM-DD” format.

source§

impl From<Date> for DateRange

source§

fn from(date: Date) -> DateRange

Create DateRange covering the supplied date.

source§

impl From<Date> for String

source§

fn from(date: Date) -> Self

Convert a Date into a String

source§

impl Ord for Date

source§

fn cmp(&self, other: &Date) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Date> for Date

source§

fn eq(&self, other: &Date) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Date> for Date

source§

fn partial_cmp(&self, other: &Date) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<&str> for Date

source§

fn try_from(date: &str) -> Result<Self>

Create a Date out of a string, returning a Result

Errors

If the date is not formatted as ‘YYYY-MM-DD’, returns an DateError::InvalidDate. Also if the date string cannot be converted into a Date, returns an DateError::InvalidDate.

§

type Error = DateError

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

impl Copy for Date

source§

impl Eq for Date

source§

impl StructuralEq for Date

source§

impl StructuralPartialEq for Date

Auto Trait Implementations§

§

impl RefUnwindSafe for Date

§

impl Send for Date

§

impl Sync for Date

§

impl Unpin for Date

§

impl UnwindSafe for Date

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<I> IntoResettable<String> for Iwhere I: Into<String>,

§

fn into_resettable(self) -> Resettable<String>

Convert to the intended resettable type
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.