Struct tz_search::TzSearch [-] [+] [src]

pub struct TzSearch {
    // some fields omitted
}

All the information required for efficient time-zone lookups.

Unless you need absolutely strict control over memory use, you probably want to call the top-level lookup, rather than going via this.

Methods

impl TzSearch

fn new() -> TzSearch

Create a new TzSearch.

This is very expensive: the initialisation routine takes a long time (15 ms, compared to 150 *nano*seconds for lookup itself), and the resulting structure uses a lot of memory. Hence, this should be called as rarely as possible.

The free-standing lookup function internally manages creating exactly one of these, and should be preferred.

fn lookup(&self, lat: f64, long: f64) -> Option<String>

Attempt to compute the timezone that the point lat, long lies in.

The latitude lat should lie in the range [-90, 90] with negative representing south, and the longitude should lie in the range [-180, 180] with negative representing west. This will fail (return None) if the point lies in the ocean.

See also: the lookup function at the top-level.

Panics

lookup will panic if either of the two ranges above are violated.

Examples

let s = tz_search::TzSearch::new();
let (lat, long) = (-33.8885, 151.1908);
assert_eq!(s.lookup(lat, long).unwrap(),
           "Australia/Sydney");

Trait Implementations

Derived Implementations

impl Debug for TzSearch

fn fmt(&self, __arg_0: &mut Formatter) -> Result