pub enum TimeType {
Show 14 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>),
}
Expand description

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>)

Implementations§

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.

Alias for TimeType::moment(::chrono::offset::Local::now().naive_local())

Helper for TimeType::days(i * 7)

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

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

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

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

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

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.

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.

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.

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.

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.

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.

Check whether a TimeType::Moment is a certain weekday. Returns an error if TimeType is not a TimeType::Moment.

Check whether a TimeType::Moment is in a certain month. Returns an error if the TimeType is not a TimeType::Moment.

Get a string representation of the variant of the TimeType instance.

Trait Implementations§

The resulting type after applying the + operator.
Performs the + operation. Read more
Performs the += operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
Performs the -= operation. Read more

Conveniance function over Daily::daily( n * 7 )

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.