badi_date/
lib.rs

1//! Dates for the Badí' (Bahá’í) calendar and conversions between Badí' and Gregorian dates.
2//!
3//! See [The Bahá’í Calendar at bahai.org](https://www.bahai.org/action/devotional-life/calendar).
4//!
5//! # Example: create [`BadiDate`]
6//!
7//! ```
8//! use badi_date::{BadiDate, BadiMonth, BadiDateOps};
9//! let badi_date = BadiDate::new(181, BadiMonth::Month(19), 19).unwrap();
10//! assert_eq!(
11//!     BadiDate::new(182, BadiMonth::Month(1), 1).unwrap(),
12//!     badi_date.add_days(1),
13//! );
14//! ```
15//!
16//! # Example: create [`LocalBadiDate`] from local [`chrono::DateTime<Tz>`] and geo [`Coordinates`]
17//!
18//! ```
19//! use badi_date::{LocalBadiDate, BadiMonth, Coordinates, FromDateTime};
20//! use chrono::TimeZone;
21//! let denver: chrono_tz::Tz = "America/Denver".parse().unwrap();
22//! let coords = Some(Coordinates::new(39.613319, -105.016647).unwrap());
23//! let date = denver.with_ymd_and_hms(2024, 3, 19, 18, 0, 0).unwrap();
24//! let badi_date = LocalBadiDate::from_datetime(date, coords).unwrap();
25//! assert_eq!(
26//!     badi_date,
27//!     LocalBadiDate::new(180, BadiMonth::Month(19), 19, denver, coords).unwrap(),
28//! );
29//! ```
30//!
31//! # Example: create [`LocalBadiDate`] from local [`chrono::DateTime<Tz>`] without [`Coordinates`]
32//!
33//! ```
34//! use badi_date::{LocalBadiDate, BadiMonth, Coordinates, FromDateTime};
35//! use chrono::TimeZone;
36//! let denver: chrono_tz::Tz = "America/Denver".parse().unwrap();
37//! let date = denver.with_ymd_and_hms(2024, 3, 19, 18, 0, 0).unwrap();
38//! let badi_date = LocalBadiDate::from_datetime(date, None).unwrap();
39//! assert_eq!(
40//!     LocalBadiDate::new(181, BadiMonth::Month(1), 1, denver, None).unwrap(),
41//!     badi_date,
42//! );
43//! ```
44
45#![warn(missing_docs)]
46#![macro_use]
47extern crate rust_i18n;
48
49rust_i18n::i18n!("locales");
50
51mod statics;
52use statics::*;
53
54mod error;
55pub use error::*;
56
57mod badi_date;
58pub use badi_date::*;
59
60mod bahai_holy_day;
61pub use bahai_holy_day::*;