Little différence between Node js and Browser in calculation
farajn opened this issue · comments
Hi,
I used this library to calculate prayer times in a browser and also in a function runing in a Node js server. I used npm to get the library and the functions was tested with Firebase function and also with Netlify functions.
The parameters used are:
- Coordinates: [45.5049, -73.7142]
- CalculationMethod: NorthAmerica
- Madhab = adhan.Madhab.Shafi
The calculated times from a JavaScript code in a browser are:
- fajr: 04:23
- sunrise: 05:54
- dhuhr: 12:54
- asr: 16:46
- maghrib: 19:52
- isha: 21:25
The calculated times from the two functions runing on a Node js server are :
- fajr: 04:21
- sunrise: 05:53
- dhuhr: 12:54
- asr: 16:47
- maghrib: 19:54
- isha: 21:27
Why we have those +/- 2 minutes differences from the two sources even if the code is the same?
Thanks.
It seems that the node server and browser may have different dates/times. The browser times are the times for April 24th and the node times are for April 25th.
Hi,
The source of the problem is that I was using new Date("2019-04-25")
instead of new Date(2019, 3, 25)
. The former is treated as UTC and the later as local time (Date doc). So, at Firebase, the server time is UTC and the calculation is correct, in my browser I have UTC-4 so the calculation was made for yesterday.
Thanks.