batoulapps / adhan-js

High precision Islamic prayer time library for JavaScript
MIT License
368 stars 81 forks source link

Reason for using sth like moment.js #140

Closed meypod closed 1 year ago

meypod commented 1 year ago

Hi I have developed an adhan app, and recently when I was reviewing my code, I just realized in adhan.js docs it mentions it uses UTC date object but this is confusing, because javascript dates are already based on UTC 0, and when you try to use their times they always show local time I mean is it really necessary to use something like moment.js ? can you clarify this ?: The prayer times will be Date object instances initialized with UTC values. You will then need to format the times for the correct timezone. You can do that by using a timezone aware date formatting library like [moment](https://momentjs.com/docs/).

redacr11 commented 1 year ago

Hello brother,

I think what they mean by that is that if you're in a different timezone, you can use moment.js to convert the time/date from UTC to a different timezone, e.g. UTC+2, UTC-4, etc...

z3bi commented 1 year ago

@meypod I guess it depends on what platform you're using. If you're in a web browser and the prayer time location is the same as the user's location then you might need another library. But if you're running a backend (like NodeJS) or displaying prayer times for a different location, then you will need something like moment or luxon to display the date in the correct time zone.