pub struct TzLocation<Tz>{ /* private fields */ }Expand description
Time zone is specified and coordinates can optionally be specified for accurate sun events.
Implementations§
Source§impl<Tz> TzLocation<Tz>
impl<Tz> TzLocation<Tz>
Sourcepub fn new(tz: Tz) -> Self
pub fn new(tz: Tz) -> Self
Create a new location context which only contains timezone information.
Sourcepub fn get_timezone(&self) -> &Tz
pub fn get_timezone(&self) -> &Tz
Extract the timezone for this location.
Sourcepub fn with_coords(self, coords: Coordinates) -> Self
pub fn with_coords(self, coords: Coordinates) -> Self
Attach coordinates to the location context.
If coordinates where already specified, they will be replaced with the new ones.
Source§impl TzLocation<Tz>
impl TzLocation<Tz>
Sourcepub fn from_coords(coords: Coordinates) -> Self
Available on crate feature auto-timezone only.
pub fn from_coords(coords: Coordinates) -> Self
auto-timezone only.Create a new location context from a set of coordinates and with timezone information inferred from this localization.
Returns None if latitude or longitude is invalid.
use chrono_tz::Europe;
use opening_hours::localization::{Coordinates, TzLocation};
let coords = Coordinates::new(48.8535, 2.34839).unwrap();
assert_eq!(
TzLocation::from_coords(coords),
TzLocation::new(Europe::Paris).with_coords(coords),
);Trait Implementations§
Source§impl<Tz> Clone for TzLocation<Tz>
impl<Tz> Clone for TzLocation<Tz>
Source§fn clone(&self) -> TzLocation<Tz>
fn clone(&self) -> TzLocation<Tz>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Tz> Debug for TzLocation<Tz>
impl<Tz> Debug for TzLocation<Tz>
Source§impl<Tz> Localize for TzLocation<Tz>
impl<Tz> Localize for TzLocation<Tz>
Source§fn naive(&self, dt: Self::DateTime) -> NaiveDateTime
fn naive(&self, dt: Self::DateTime) -> NaiveDateTime
Get naive local time.
Source§fn datetime(&self, naive: NaiveDateTime) -> Self::DateTime
fn datetime(&self, naive: NaiveDateTime) -> Self::DateTime
Localize a naive datetime.
Source§impl<Tz> PartialEq for TzLocation<Tz>
impl<Tz> PartialEq for TzLocation<Tz>
impl<Tz> StructuralPartialEq for TzLocation<Tz>
Auto Trait Implementations§
impl<Tz> Freeze for TzLocation<Tz>where
Tz: Freeze,
impl<Tz> RefUnwindSafe for TzLocation<Tz>where
Tz: RefUnwindSafe,
impl<Tz> Send for TzLocation<Tz>
impl<Tz> Sync for TzLocation<Tz>
impl<Tz> Unpin for TzLocation<Tz>where
Tz: Unpin,
impl<Tz> UnsafeUnpin for TzLocation<Tz>where
Tz: UnsafeUnpin,
impl<Tz> UnwindSafe for TzLocation<Tz>where
Tz: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more