batoulapps / adhan-js

High precision Islamic prayer time library for JavaScript
MIT License
387 stars 87 forks source link

Little différence between Node js and Browser in calculation #4

Closed farajn closed 5 years ago

farajn commented 5 years ago

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:

The calculated times from a JavaScript code in a browser are:

The calculated times from the two functions runing on a Node js server are :

Why we have those +/- 2 minutes differences from the two sources even if the code is the same?

Thanks.

z3bi commented 5 years ago

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.

farajn commented 5 years ago

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.