Crate badi_date

Source
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!(
    badi_date,
    LocalBadiDate::new(180, BadiMonth::Month(19), 19, denver, coords).unwrap(),
);

§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§

BadiDate
A structure that holds a date in the Badí‘ (Bahá’í) calendar without time zone or location info
Coordinates
WGS-84 GPS coordinates used to calculate sunset times for a LocalBadiDate
LocalBadiDate
A structure that holds a date in the Badí‘ (Bahá’í) calendar with associated time zone and optional coordinates

Enums§

BadiDateError
Error returned from trying to construct a BadiDateLike with invalid parameters
BadiMonth
Represents one of the 19 Bahá’í months or Ayyám-i-Há
BahaiHolyDay
List of the 11 Bahá’í Holy Days (9 on which work is to be suspended) See https://www.bahai.org/action/devotional-life/calendar
CoordinatesError
Error returned for invalid Coordinates
DayChangeAction
Determines resulting day in a returned BadiDateLike copy when adding/subtracting BadiMonths

Traits§

BadiDateLike
Common trait for BadiDate and LocalBadiDate
BadiDateOps
Provides methods to return a modified copy of a BadiDateLike
FromDateTime
Provides methods to create a LocalBadiDate from a Gregorian DateTime
HolyDayProviding
Provides methods to get the current, previous, and next Bahá’í holy day
LocalBadiDateLike
Provides localization attributes for LocalBadiDate
ToDateTime
Provides methods to convert LocalBadiDate to a local Gregorian DateTime<Tz>