hablullah / go-prayer

Go package for getting salat times in a specific location
MIT License
58 stars 7 forks source link

Does not work for NA #1

Closed Dontmindmes closed 5 years ago

Dontmindmes commented 5 years ago

Hey North America Isnt working for some reason

https://gyazo.com/a2856306682919b05dc00e8542aba7bb

when i print it i get these times [{"fajir":"17:43","duhur":"17:43","asr":"06:38","magrib":"10:05","isha":"11:48"}]]

these times are way way off

RadhiFadlillah commented 5 years ago

Hi @Dontmindmes, sorry for late response.

I've test it and it works properly. It seems you forgot to change the timezone and the calculation method.

Since you didn't mention in which North America you are, I will use Los Angeles as example :

Now, the code should look like this (playground):

package main

import (
    "fmt"
    "time"

    "github.com/RadhiFadlillah/go-prayer"
)

func main() {
    cfg := prayer.Config{
        Latitude:             34.0522300,
        Longitude:            -118.2436800,
        Elevation:            96,
        CalculationMethod:    prayer.ISNA,
        AsrCalculationMethod: prayer.Shafii,
        PreciseToSeconds:     false,
    }

    location := time.FixedZone("PDT", -7*3600)
    date := time.Date(2019, 5, 24, 0, 0, 0, 0, location)
    times := prayer.Calculate(date, cfg)

    fmt.Println(date.Format("2006-01-02"))
    fmt.Println("Fajr    =", times.Fajr.Format("15:04"))
    fmt.Println("Sunrise =", times.Sunrise.Format("15:04"))
    fmt.Println("Zuhr    =", times.Zuhr.Format("15:04"))
    fmt.Println("Asr     =", times.Asr.Format("15:04"))
    fmt.Println("Maghrib =", times.Maghrib.Format("15:04"))
    fmt.Println("Isha    =", times.Isha.Format("15:04"))
}

Which will print this output :

2019-05-24
Fajr    = 04:25
Sunrise = 05:44
Zuhr    = 12:52
Asr     = 16:35
Maghrib = 19:56
Isha    = 21:15

Which is quite accurate if compared with MuslimPro :

muslimpro-los-angeles


The Zuhr time has two minutes difference, because AFAIK there are some difference of opinions on when azan for Zuhr should be commenced.

As we know, Zuhr time begins at the noon. However, there is hadith that forbade us to pray at the exactly middle of the day when sun is right above our head. Instead, we should wait until the sun has descended a bit to the west.

From this hadith, there are two different opinion on when azan should be announced :

  1. The azan should be announced after the sun has descended a bit (noon + 1-2 minute).
  2. The azan is announced right on noon when the sun is in the middle of the sky, since the prayer will be done later anyway (after iqamah).

Since my country uses the first option, I set it as default in this package. If you prefer the second options, you can easily correct the time using TimeCorrections.

For more details about Zuhr, you can check this out.

RadhiFadlillah commented 5 years ago

Since it seems there are no problem anymore, I will close this issue. Feels free to reopen it if needed.