#time #zone #timezone

zone-detect

Rust version of the ZoneDetect C library

3 releases (1 stable)

1.0.0 Sep 6, 2021
0.2.0 Jan 27, 2020
0.1.0 Jan 25, 2020

#254 in Date and time

Download history 13/week @ 2023-01-27 11/week @ 2023-02-03 12/week @ 2023-02-10 9/week @ 2023-02-17 8/week @ 2023-03-03 13/week @ 2023-03-10 5/week @ 2023-03-17 11/week @ 2023-03-24 3/week @ 2023-03-31 9/week @ 2023-04-07 6/week @ 2023-04-14 25/week @ 2023-04-21 57/week @ 2023-04-28 15/week @ 2023-05-05 2/week @ 2023-05-12

100 downloads per month

BSD-3-Clause

3.5MB
950 lines

zone-detect

This is a Rust version of the ZoneDetect C library. The initial conversion was done with c2rust, then manually cleaned up (it no longer contains any unsafe code).

This crate can be used to look up the country and timezone of any location on Earth.

Running the example

cargo run --example demo data/timezone21.bin 35.0715 -82.5216

Data source

The database containing the location and timezone data is in data/timezone21.bin. It can be updated as follows:

git clone https://github.com/BertoldVdb/ZoneDetect
cd ZoneDetect/database/builder
./makedb.sh

This will produce, among other things, out_v1/timezone21.bin.


lib.rs:

Example:

let database = zone_detect::Database::open("data/timezone21.bin")
    .expect("failed to open database");
let s = database.simple_lookup(zone_detect::Location {
    latitude: 35.0715,
    longitude: -82.5216,
}).unwrap();
assert_eq!(s, "America/New_York");

Dependencies