Enum kairos::timetype::TimeType
[−]
[src]
pub enum TimeType { Seconds(i64), Minutes(i64), Hours(i64), Days(i64), Months(i64), Years(i64), Moment(NaiveDateTime), Addition(Box<TimeType>, Box<TimeType>), Subtraction(Box<TimeType>, Box<TimeType>), EndOfYear(Box<TimeType>), EndOfMonth(Box<TimeType>), EndOfDay(Box<TimeType>), EndOfHour(Box<TimeType>), EndOfMinute(Box<TimeType>), }
A Type of Time, currently based on chrono::NaiveDateTime
Variants
Seconds(i64)
Minutes(i64)
Hours(i64)
Days(i64)
Months(i64)
Years(i64)
Moment(NaiveDateTime)
Addition(Box<TimeType>, Box<TimeType>)
Subtraction(Box<TimeType>, Box<TimeType>)
EndOfYear(Box<TimeType>)
EndOfMonth(Box<TimeType>)
EndOfDay(Box<TimeType>)
EndOfHour(Box<TimeType>)
EndOfMinute(Box<TimeType>)
Methods
impl TimeType
[src]
The TimeType type
Warning
If the TimeType is larger than the queried type (E.G. querying a "minutes" on a "month"), the following rules are applied:
- 60 Seconds make a Minute
- 60 Minutes make a Hour
- 24 Hours make a Day
- 7 Days make a Week
- 4 Weeks make a Month
- 12 Months make a Year
Whether these may be correct or not in the current year. The return value of the function
is calculated appropriately. So, calling the get_seconds()
function on 5 minutes returns
60 * 5
.
If the TimeType is smaller than the queried type (E.G. querying a "month" on a "minutes"), zero is returned.
Also, if the TimeType is "5 weeks", querying a month returns 1
, as 5 weeks contain one
full month.
fn today() -> TimeType
[src]
Alias for TimeType::moment(::chrono::offset::Local::now().naive_local())
fn is_a_amount(&self) -> bool
[src]
fn is_moment(&self) -> bool
[src]
fn is_addition(&self) -> bool
[src]
fn is_subtraction(&self) -> bool
[src]
fn seconds(i: i64) -> TimeType
[src]
fn minutes(i: i64) -> TimeType
[src]
fn hours(i: i64) -> TimeType
[src]
fn days(i: i64) -> TimeType
[src]
fn weeks(i: i64) -> TimeType
[src]
Helper for TimeType::days(i * 7)
fn months(i: i64) -> TimeType
[src]
fn years(i: i64) -> TimeType
[src]
fn moment(ndt: NaiveDateTime) -> TimeType
[src]
fn end_of_year(self) -> TimeType
[src]
Calculate the end of the year based on the current TimeType
The end of a year is considered to be the last day of the year, not the last second.
Warning
If the current TimeType does not evaluate to a TimeType::Moment
, calculating the end of
the year will fail
fn end_of_month(self) -> TimeType
[src]
Calculate the end of the month based on the current TimeType
The end of a month is considered to be the last day of the month, not the last second.
Warning
If the current TimeType does not evaluate to a TimeType::Moment
, calculating the end of
the month will fail
fn end_of_day(self) -> TimeType
[src]
Calculate the end of the day based on the current TimeType
The end of a day is considered the last second of the day
Warning
If the current TimeType does not evaluate to a TimeType::Moment
, calculating the end of
the day will fail
fn end_of_hour(self) -> TimeType
[src]
Calculate the end of the hour based on the current TimeType
The end of a hour is considered the last second of a hour
Warning
If the current TimeType does not evaluate to a TimeType::Moment
, calculating the end of
the hour will fail
fn end_of_minute(self) -> TimeType
[src]
Calculate the end of the minute based on the current TimeType
The end of a minute is considered to be the last second of a minute
Warning
If the current TimeType does not evaluate to a TimeType::Moment
, calculating the end of
the minute will fail
fn get_seconds(&self) -> i64
[src]
Get the number of seconds, if the TimeType is not a duration type, zero is returned
Warning
If the type is actually a smaller one (eg. calling get_minutes() on a seconds instance) the following rules are applied:
- A minute is 60 seconds
- A hour is 60 minutes
- A day is 24 hours
- A month is 30 days
- A year is 12 months
Which might not be always correct.
fn get_minutes(&self) -> i64
[src]
Get the number of minutes, if the TimeType is not a duration type, zero is returned
Warning
If the type is actually a smaller one (eg. calling get_minutes() on a seconds instance) the following rules are applied:
- A minute is 60 seconds
- A hour is 60 minutes
- A day is 24 hours
- A month is 30 days
- A year is 12 months
Which might not be always correct.
fn get_hours(&self) -> i64
[src]
Get the number of hours, if the TimeType is not a duration type, zero is returned
Warning
If the type is actually a smaller one (eg. calling get_minutes() on a seconds instance) the following rules are applied:
- A minute is 60 seconds
- A hour is 60 minutes
- A day is 24 hours
- A month is 30 days
- A year is 12 months
Which might not be always correct.
fn get_days(&self) -> i64
[src]
Get the number of days, if the TimeType is not a duration type, zero is returned
Warning
If the type is actually a smaller one (eg. calling get_minutes() on a seconds instance) the following rules are applied:
- A minute is 60 seconds
- A hour is 60 minutes
- A day is 24 hours
- A month is 30 days
- A year is 12 months
Which might not be always correct.
fn get_months(&self) -> i64
[src]
Get the number of months, if the TimeType is not a duration type, zero is returned
Warning
If the type is actually a smaller one (eg. calling get_minutes() on a seconds instance) the following rules are applied:
- A minute is 60 seconds
- A hour is 60 minutes
- A day is 24 hours
- A month is 30 days
- A year is 12 months
Which might not be always correct.
fn get_years(&self) -> i64
[src]
Get the number of years, if the TimeType is not a duration type, zero is returned
Warning
If the type is actually a smaller one (eg. calling get_minutes() on a seconds instance) the following rules are applied:
- A minute is 60 seconds
- A hour is 60 minutes
- A day is 24 hours
- A month is 30 days
- A year is 12 months
Which might not be always correct.
fn get_moment(&self) -> Option<&NaiveDateTime>
[src]
fn is_a(&self, d: Day) -> Result<bool>
[src]
Check whether a TimeType::Moment
is a certain weekday. Returns an error if TimeType is
not a TimeType::Moment
.
fn is_in(&self, month: Month) -> Result<bool>
[src]
Check whether a TimeType::Moment
is in a certain month. Returns an error if the TimeType
is not a TimeType::Moment
.
fn name(&self) -> &'static str
[src]
Get a string representation of the variant of the TimeType
instance.
fn calculate(self) -> Result<TimeType>
[src]
Trait Implementations
impl Minutely for TT
[src]
impl Hourly for TT
[src]
impl Daily for TT
[src]
impl Weekly for TT
[src]
impl Monthly for TT
[src]
impl Yearly for TT
[src]
impl Every for TT
[src]
impl Debug for TimeType
[src]
impl Clone for TimeType
[src]
fn clone(&self) -> TimeType
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl PartialEq for TimeType
[src]
fn eq(&self, __arg_0: &TimeType) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &TimeType) -> bool
[src]
This method tests for !=
.
impl Eq for TimeType
[src]
impl PartialOrd for TimeType
[src]
fn partial_cmp(&self, __arg_0: &TimeType) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &TimeType) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &TimeType) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &TimeType) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &TimeType) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for TimeType
[src]
fn cmp(&self, __arg_0: &TimeType) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl Add for TimeType
[src]
type Output = TimeType
The resulting type after applying the +
operator.
fn add(self, rhs: TimeType) -> Self::Output
[src]
Performs the +
operation.
impl AddAssign for TimeType
[src]
fn add_assign(&mut self, rhs: TimeType)
[src]
Performs the +=
operation.
impl Sub for TimeType
[src]
type Output = TimeType
The resulting type after applying the -
operator.
fn sub(self, rhs: TimeType) -> Self::Output
[src]
Performs the -
operation.
impl SubAssign for TimeType
[src]
fn sub_assign(&mut self, rhs: TimeType)
[src]
Performs the -=
operation.