prayer-times-cli

1.0.0 • Public • Published

Prayer Times CLI A simple and easy-to-use npm package for fetching Islamic prayer times using the Aladhan API.

Features Fetches prayer times for a specific city and country for an entire month. Easy integration into any Node.js application. Converts prayer times to a 12-hour format.

Installation

npm install prayer-cli

Usage

import { fetchPrayerTimesByCity, tConv24 } from "prayer-cli";

const city = "New York"; const country = "United States"; const year = new Date().getFullYear(); const month = new Date().getMonth() + 1; const method = 2;

async function displayPrayerTimes() { const data = await fetchPrayerTimesByCity(year, month, city, country, method);

if (data) { data.data.forEach((dayData) => { console.log(🧭 ${city}, ${country}); console.log(📆 ${dayData.date.readable}\n); console.log(◽ Fajr --> ${tConv24(dayData.timings.Fajr)}); console.log(◽ Dhuhr --> ${tConv24(dayData.timings.Dhuhr)}); console.log(◽ Asr --> ${tConv24(dayData.timings.Asr)}); console.log(◽ Maghrib --> ${tConv24(dayData.timings.Maghrib)}); console.log(◽ Isha --> ${tConv24(dayData.timings.Isha)}); console.log("-------"); }); } else { console.error("Error fetching prayer times"); } }

displayPrayerTimes(); API fetchPrayerTimesByCity(year: number, month: number, city: string, country: string, method?: number): Promise<ApiResponse | null> Fetches prayer times for the given year, month, city, and country. Optionally, you can specify a calculation method using the method parameter.

Returns a Promise that resolves to an ApiResponse object, or null if there's an error.

tConv24(time24: string): string Converts the given 24-hour time string to a 12-hour format with AM/PM.

Contributing Feel free to open issues or submit pull requests for any bugs or feature requests.

License This project is licensed under the ISC License.

Readme

Keywords

none

Package Sidebar

Install

npm i prayer-times-cli

Weekly Downloads

2

Version

1.0.0

License

ISC

Unpacked Size

28.3 kB

Total Files

7

Last publish

Collaborators

  • mehboob_khan