azzamsa / islam

Islamic library for Rust
GNU General Public License v3.0
17 stars 4 forks source link

fix: current prayer time 0:0 if next prayer fajr #4

Closed Moanrisy closed 1 year ago

Moanrisy commented 1 year ago

Bug: remaining time before next prayer is showing 0:0 if current prayer is isya

The usual next_prayer - current_time not gonna work Because fajr time value is less than current time (after isya)

azzamsa commented 1 year ago

Thanks for finding all the bugs and all your awesome PRs! :heart:

I use this simpler approach instead.

        // Special case if the next prayer time is on the following day
        if self.next() == Prayer::FajrTomorrow {
            // Current time is after midnight
            if now.time() < self.fajr_tomorrow.time() {
                now += Duration::days(1);
            }
        }