1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
//! A Rust library for parsing and working with OSM's opening hours field. You can //! find its specification [here](https://wiki.openstreetmap.org/wiki/Key:opening_hours/specification) //! and the reference JS library [here](https://github.com/opening-hours/opening_hours.js). //! //! Note that the specification is quite messy and that the JS library takes //! liberty to extend it quite a lot. This means that most of the real world data //! don't actually comply to the very restrictive grammar detailed in the official //! specification. This library tries to fit with the real world data while //! remaining as close as possible to the core specification. //! //! //! Usage //! ----- //! //! Add this to your `Cargo.toml`: //! //! ```toml //! [dependencies] //! opening-hours = "0" //! ``` //! //! Here's a simple example that parse an opening hours description and displays //! its current status and date for next change: //! //! ```rust //! use chrono::Local; //! use opening_hours::OpeningHours; //! //! // Opens until 18pm during the week and until 12am the week-end. //! const OH: &str = "Mo-Fr 10:00-18:00; Sa-Su 10:00-12:00"; //! //! fn main() { //! let oh = OpeningHours::parse(&OH).unwrap(); //! let date = Local::now().naive_local(); //! println!("Current status is {:?}", oh.state(date).unwrap()); //! println!("This will change at {:?}", oh.next_change(date).unwrap()); //! } //! ``` //! //! //! Supported features //! ------------------ //! //! ### Holidays //! //! A public holiday database is loaded using Python library [workalendar]. You //! should refer to Python library for more information on which countries are //! supported. //! //! Holidays are not loaded beyond year 2050 to avoid having a huge binary. //! //! //! ### Syntax //! //! If you are only interested in parsing expressions but not on the evaluation or //! if you want to build your own evaluation engine, you should probably rely on //! the [opening-hours-syntax] crate. //! //! //! //! [opening-hours]: https://crates.io/crates/opening-hours //! "Package" //! //! [opening-hours-syntax]: https://crates.io/crates/opening-hours-syntax //! "Syntax Package" //! //! [docs]: https://docs.rs/opening-hours //! "Documentation" //! //! [pypy]: https://pypi.org/project/opening-hours-py //! "Python package" //! //! [codecov]: https://app.codecov.io/gh/remi-dupre/opening-hours-rs //! "Code coverage" //! //! [workalendar]: https://pypi.org/project/workalendar/ //! "Worldwide holidays and working days helper and toolkit." pub mod date_filter; #[macro_use] pub mod schedule; pub mod opening_hours; pub mod time_filter; mod utils; #[cfg(test)] mod tests; // Public re-exports // TODO: make opening_hours.rs lighter and less spaghetty pub use crate::opening_hours::OpeningHours; pub use crate::utils::range::DateTimeRange; pub use opening_hours_syntax::error::Error as ParserError;