diff --git a/Cargo.toml b/Cargo.toml index 358e71f..e31f187 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "salah" -version = "0.7.1" +version = "0.7.5" authors = ["Farhan Ahmed "] edition = "2018" description = "Islamic prayer time library for Rust" diff --git a/README.md b/README.md index 500f9a5..9e0d80d 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Add the following to your `Cargo.toml` file under the `[dependencies]` section: ``` [dependencies] -salah = "0.7.1" +salah = "0.7.5" ``` To get prayer times, use the `PrayerSchedule` struct passing in coordinates, date, and calculation parameters. @@ -24,7 +24,7 @@ To get prayer times, use the `PrayerSchedule` struct passing in coordinates, dat use salah::prelude::*; let new_york_city = Coordinates::new(40.7128, -74.0059); -let date = Utc.ymd(2019, 1, 25); +let date = NaiveDate::from_ymd_opt(2019, 1, 25).expect("Invalid date provided"); let params = Configuration::with(Method::MoonsightingCommittee, Madhab::Hanafi); let prayers = PrayerSchedule::new() .on(date) @@ -134,7 +134,7 @@ Shafaq is used by the MoonsightingCommittee method to determine what type of twi ### Prayer Schedule The `PrayerSchedule` struct is a builder for the the `PrayerTimes` struct. Once the `calculate()` method is invoked on it, a `PrayerTime` struct will be initialized and it will contain fields -for all five prayer times, the time for sunrise, and for the Qiyam prayer. +for all five prayer times, the time for sunrise, and for the Qiyam prayer. The prayer time will be an instance of `DateTime` and as such will refer to a fixed point in universal time. To display these times for the local timezone you will need to format them with the appropriate local time zone. diff --git a/src/astronomy/solar.rs b/src/astronomy/solar.rs index e49bf43..4439017 100644 --- a/src/astronomy/solar.rs +++ b/src/astronomy/solar.rs @@ -200,6 +200,12 @@ impl SolarTime { let adjusted_mins = (calculated_minutes + calculated_seconds / 60.0).round() as u32; let adjusted_secs: u32 = 0; + let (hour, mins, secs) = if adjusted_mins > 59 { + (adjusted_hour + 1, 0, adjusted_secs) + } else { + (adjusted_hour, adjusted_mins, adjusted_secs) + }; + let adjusted = Utc .with_ymd_and_hms( adjusted_date.year(), diff --git a/src/lib.rs b/src/lib.rs index 6376458..0c558da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -282,4 +282,18 @@ mod tests { Err(_err) => assert!(false), } } + + #[test] + fn calculate_time_for_kuala_lumpur() { + let location = Coordinates::new(3.12, 101.69); + let date = NaiveDate::from_ymd_opt(2024, 4, 9).expect("Invalid date provided"); + let params = Configuration::with(Method::MuslimWorldLeague, Madhab::Shafi); + let result = PrayerSchedule::new() + .on(date) + .for_location(location) + .with_configuration(params) + .calculate(); + + assert!(result.is_ok()); + } }