[][src]Struct holding_kronos::Calendar

pub struct Calendar { /* fields omitted */ }

Allows manipulation of dates.

Implementations

impl Calendar[src]

pub fn new(months: Vec<Month>, week_days: Week, eras: Eras) -> Self[src]

Creates a new Calendar given a number of months, week days, and eras.

pub fn hours_in_day(&self) -> u32[src]

Gets the hours in the day for this calendar.

pub fn days_in_year(&self) -> u32[src]

Gets the days in a year for this calendar.

pub fn days_in_week(&self) -> u32[src]

Gets the days in a year for this calendar.

pub fn years_to_seconds(&self, years: i64) -> i64[src]

Gets the number of seconds corresponding to a number of years.

pub fn months_to_seconds(&self, month: u32) -> u32[src]

Given a month, calculates the seconds that pass between the beginning of the year and the end of that month.

Note that since months are irregular (have different lengths) this is always relative to the start of the year.

Example: calendar.months_to_seconds(3) = January + February + March

todo(arlyon) return result if month is out of range

pub fn days_to_seconds(&self, days: u32) -> u32[src]

Gets the number of seconds corresponding to a number of days.

pub fn hours_to_seconds(&self, hours: u32) -> u32[src]

Gets the number of seconds corresponding to a number of hours.

pub fn minutes_to_seconds(&self, minutes: u32) -> u32[src]

Gets the number of seconds corresponding to a number of minutes.

pub fn years(&self, seconds: i64) -> i64[src]

Extracts the year component from a time. This does not respect the era. In that case please use Calendar::year.

The year component is 0-indexed.

pub fn months(&self) -> &[Month][src]

Gets the list of months in this calendar.

pub fn month(&self, seconds: i64) -> u32[src]

Extracts the month component from a time.

The month component is 1-indexed.

pub fn day(&self, seconds: i64) -> u32[src]

Extracts the days component from a time.

The day component is 1-indexed.

pub fn hour(&self, seconds: i64) -> u32[src]

Extracts the hours component from a time.

The hour component is 0-indexed.

pub fn minute(&self, seconds: i64) -> u32[src]

Extracts the minutes component from a time.

The minutes component is 0-indexed.

pub fn second(&self, seconds: i64) -> u32[src]

Extracts the seconds component from a time.

The seconds component is 0-indexed.

pub fn eras(&self) -> &[Era][src]

Gets a slice into the Eras in this calendar.

pub fn get_era(&self, year: i64) -> (usize, &Era)[src]

Gets an era by year.

pub fn week_day(&self, era: usize, seconds: i64) -> usize[src]

Gets the day of the week for a given DateTime.

This requires the era because the number of days in a year is not alwyas 0 modulo the days in the week.

This is 1-indexed.

pub fn week_day_name(&self, era: usize, seconds: i64) -> &str[src]

Gets the name of the week for a given time.

pub fn month_day(&self, seconds: i64) -> u32[src]

Gets the day of the month for a given DateTime.

The month-day component is 1-indexed.

pub fn month_name(&self, seconds: i64) -> &str[src]

Gets the name of the month for a given DateTime.

pub fn time(&self, seconds: i64) -> u32[src]

Get the time component (ie. modulo days).

This is nonnegative.

pub fn year(&self, era: usize, seconds: i64) -> i64[src]

Gets the year at an offset to a given era.

The year component is 1-indexed.

pub fn parse<'a>(
    &'a self,
    date_string: &str,
    relative_to: Option<DateTime>
) -> Result<DateTime, DateTimeParseError>
[src]

Parses human times such as 1d8h43m into datetime objects according to the rules of the calendar.

1101-02-12 - some specific date 8am, 2pm - some specific time 1y32mo6d3s - relative from some time long rest - exactly 8 hours short rest - exactly 4 hours

Trait Implementations

impl Clone for Calendar[src]

impl Debug for Calendar[src]

impl Default for Calendar[src]

impl<'de> Deserialize<'de> for Calendar[src]

impl Serialize for Calendar[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.