Expand description
Dates for the Badí’ (Bahá’í) calendar and conversions between Badí’ and Gregorian dates.
See The Bahá’í Calendar at bahai.org.
§Example: create BadiDate
use badi_date::{BadiDate, BadiMonth, BadiDateOps};
let badi_date = BadiDate::new(181, BadiMonth::Month(19), 19).unwrap();
assert_eq!(
BadiDate::new(182, BadiMonth::Month(1), 1).unwrap(),
badi_date.add_days(1),
);§Example: create LocalBadiDate from local chrono::DateTime<Tz> and geo Coordinates
use badi_date::{LocalBadiDate, BadiMonth, Coordinates, FromDateTime};
use chrono::TimeZone;
let denver: chrono_tz::Tz = "America/Denver".parse().unwrap();
let coords = Some(Coordinates::new(39.613319, -105.016647).unwrap());
let date = denver.with_ymd_and_hms(2024, 3, 19, 18, 0, 0).unwrap();
let badi_date = LocalBadiDate::from_datetime(date, coords).unwrap();
assert_eq!(
LocalBadiDate::new(180, BadiMonth::Month(19), 19, denver, coords).unwrap(),
badi_date,
);§Example: create LocalBadiDate from local chrono::DateTime<Tz> without Coordinates
use badi_date::{LocalBadiDate, BadiMonth, Coordinates, FromDateTime};
use chrono::TimeZone;
let denver: chrono_tz::Tz = "America/Denver".parse().unwrap();
let date = denver.with_ymd_and_hms(2024, 3, 19, 18, 0, 0).unwrap();
let badi_date = LocalBadiDate::from_datetime(date, None).unwrap();
assert_eq!(
LocalBadiDate::new(181, BadiMonth::Month(1), 1, denver, None).unwrap(),
badi_date,
);Structs§
- A structure that holds a date in the Badí‘ (Bahá’í) calendar without time zone or location info
- WGS-84 GPS coordinates used to calculate sunset times for a
LocalBadiDate - A structure that holds a date in the Badí‘ (Bahá’í) calendar with associated time zone and optional coordinates
Enums§
- Error returned from trying to construct a
BadiDateLikewith invalid parameters - Represents one of the 19 Bahá’í months or Ayyám-i-Há
- Error returned for invalid
Coordinates - Determines resulting day in a returned
BadiDateLikecopy when adding/subtractingBadiMonths
Traits§
- Common trait for
BadiDateandLocalBadiDate - Provides methods to return a modified copy of a
BadiDateLike - Provides methods to create a
LocalBadiDatefrom a GregorianDateTime - Provides localization attributes for
LocalBadiDate - Provides methods to convert
LocalBadiDateto a local GregorianDateTime<Tz>
Functions§
- Lookup fallback locales
- Get I18n text by locale and key