schedule_builder/
schedule-builder.rs1use chrono::Local;
2use mawaqit::prelude::*;
3
4fn print_prayers(prayers: &PrayerTimes) {
5 for prayer in &[
6 Prayer::Fajr,
7 Prayer::Sunrise,
8 Prayer::Dhuhr,
9 Prayer::Asr,
10 Prayer::Maghrib,
11 Prayer::Isha,
12 ] {
13 let local = prayers.time(*prayer).with_timezone(&Local);
14 println!(" {prayer:>8?} {}", local.format("%H:%M"));
15 }
16}
17
18fn main() {
19 let result = PrayerSchedule::new()
21 .on(NaiveDate::from_ymd_opt(2026, 6, 21).expect("invalid date"))
22 .for_location(Coordinates::new(50.85, 4.35)) .with_configuration(Configuration::with(
24 Method::MuslimWorldLeague,
25 Madhab::Shafi,
26 ))
27 .calculate();
28
29 match result {
30 Ok(prayers) => {
31 println!("Brussels — 2026-06-21 (MWL, Shafi):");
32 print_prayers(&prayers);
33 }
34 Err(e) => {
35 eprintln!("Error: {e}");
36 }
37 }
38
39 let incomplete = PrayerSchedule::new()
41 .on(NaiveDate::from_ymd_opt(2026, 6, 21).expect("invalid date"))
42 .calculate();
43
44 match incomplete {
45 Ok(_) => println!("unexpected success"),
46 Err(e) => println!("\nExpected error: {e}"),
47 }
48}