
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Namaz JS is a well tested and well documented library for calculating Islamic prayer times in JavaScript using Node or a web browser. This works great all countries of the world especially in Pakistan, India, Bangladesh and neighbouring countries.
You can even get prayer time in seconds for greater precision and your own calculations.
All astronomical calculations are high precision equations directly from the book “Astronomical Algorithms” by Jean Meeus. This book is recommended by the Astronomical Applications Department of the U.S. Naval Observatory and the Earth System Research Laboratory of the National Oceanic and Atmospheric Administration.
Namaz was designed to work in the browser and in Node.js
<script src="Adhan.js"></script>
<script>
var prayerTimes = new adhan.PrayerTimes(coordinates, date, params, precisionOn));
</script>
npm install azan-js
var adhan = require('namaz-js')
var prayerTimes = new adhan.PrayerTimes(coordinates, date, params, precisionOn);
Migrating from version 3.x? Read the migration guide
To get prayer times initialize a new PrayerTimes object passing in coordinates,
date, and calculation parameters.
var prayerTimes = new adhan.PrayerTimes(coordinates, date, params, precisionOn);
Create a Coordinates object with the latitude and longitude for the location
you want prayer times for.
var coordinates = new adhan.Coordinates(35.78056, -78.6389);
The date parameter passed in should be an instance of the JavaScript Date
object. The year, month, and day values need to be populated. All other
values will be ignored. The year, month and day values should be for the date
that you want prayer times for. These date values are expected to be for the
Gregorian calendar.
var date = new Date();
var date = new Date(2015, 11, 1);
The rest of the needed information is contained within the CalculationParameters object.
Calculation Parameters & Methods Guide
If you also want to get seconds in prayer times you need to pass precisionOn boolean parameter to PrayerTimes constructor. If true you will get seconds in prayer times as well. Don't forget to use time format that displays seconds e.g h:mm:ss A
Once the PrayerTimes object has been initialized it will contain values
for all five prayer times and the time for sunrise. 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.
moment(prayerTimes.fajr).tz('America/New_York').format('h:mm A');
Or if precisionOn is true
moment(prayerTimes.fajr).tz('America/New_York').format('h:mm:ss A');
var date = new Date();
var coordinates = new adhan.Coordinates(35.78056, -78.6389);
var params = adhan.CalculationMethod.MuslimWorldLeague();
var precisionOn = true;
params.madhab = adhan.Madhab.Hanafi;
var prayerTimes = new adhan.PrayerTimes(coordinates, date, params, precisionOn);
var fajrTime = moment(prayerTimes.fajr).tz('America/New_York').format('h:mm:ss A');
var sunriseTime = moment(prayerTimes.sunrise).tz('America/New_York').format('h:mm:ss A');
var dhuhrTime = moment(prayerTimes.dhuhr).tz('America/New_York').format('h:mm:ss A');
var asrTime = moment(prayerTimes.asr).tz('America/New_York').format('h:mm:ss A');
var maghribTime = moment(prayerTimes.maghrib).tz('America/New_York').format('h:mm:ss A');
var ishaTime = moment(prayerTimes.isha).tz('America/New_York').format('h:mm:ss A');
The PrayerTimes object has functions for getting the current prayer and the next prayer. You can also get the time for a specified prayer, making it
easier to dynamically show countdowns until the next prayer.
var prayerTimes = new adhan.PrayerTimes(coordinates, date, params, precisionOn);
var current = prayerTimes.currentPrayer();
var next = prayerTimes.nextPrayer();
var nextPrayerTime = prayerTimes.timeForPrayer(next);
The Namaz JS library can also calulate Sunnah times. Given an instance of PrayerTimes, you can get a SunnahTimes object with the times for Qiyam.
var sunnahTimes = new adhan.SunnahTimes(prayerTimes);
var middleOfTheNight = moment(sunnahTimes.middleOfTheNight).tz('America/New_York').format('h:mm A');
var lastThirdOfTheNight = moment(sunnahTimes.lastThirdOfTheNight).tz('America/New_York').format('h:mm A');
Get the direction, in degrees from North, of the Qibla from a given set of coordinates.
var coordinates = new adhan.Coordinates(35.78056, -78.6389);
var qiblaDirection = adhan.Qibla(coordinates);
Namaz is made publicly available to provide a well tested and well documented library for Islamic prayer times to all developers. We accept feature contributions provided that they are properly documented and include the appropriate unit tests. We are also looking for contributions in the form of unit tests of of prayer times for different locations, we do ask that the source of the comparison values be properly documented.
Note: Commit messages should follow the commit message convention so that changelogs can be automatically generated. Commit messages will be automatically validated upon commit. If you are not familiar with the commit message convention, you should use npm run commit instead of git commit, which provides an interactive CLI for generating proper commit messages.
Azan is available under the MIT license. See the LICENSE file for more info.
FAQs
High precision Islamic prayer time library for Pakistan and other countries
We found that namaz-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.