Skip to main content

Localize

Trait Localize 

Source
pub trait Localize:
    Clone
    + Send
    + Sync {
    type DateTime: Clone + Add<Duration, Output = Self::DateTime>;

    // Required methods
    fn naive(&self, dt: Self::DateTime) -> NaiveDateTime;
    fn datetime(&self, naive: NaiveDateTime) -> Self::DateTime;

    // Provided method
    fn event_time(&self, _date: NaiveDate, event: TimeEvent) -> NaiveTime { ... }
}
Expand description

Specifies how dates should be localized while evaluating opening hours. No localisation is available by default but this can be used to specify a timezone and coordinates (which affect sun events).

Required Associated Types§

Source

type DateTime: Clone + Add<Duration, Output = Self::DateTime>

The type for localized date & time.

Required Methods§

Source

fn naive(&self, dt: Self::DateTime) -> NaiveDateTime

Get naive local time.

Source

fn datetime(&self, naive: NaiveDateTime) -> Self::DateTime

Localize a naive datetime.

Provided Methods§

Source

fn event_time(&self, _date: NaiveDate, event: TimeEvent) -> NaiveTime

Get the localized time for a sun event at a given date.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§