Skip to content

Commit

Permalink
ensuring compatibility with new changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashraf-Ali-aa committed Sep 21, 2023
1 parent 33b5dc7 commit bfe5960
Show file tree
Hide file tree
Showing 19 changed files with 435 additions and 84 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prayersconnect/configs",
"version": "3.6.0",
"version": "3.7.0",
"description": "Country specific configuration for Prayers Connect",
"main": "./lib/index.js",
"typings": "./lib/index.d.ts",
Expand All @@ -17,6 +17,7 @@
"build": "tsc --build tsconfig.json",
"prepare": "husky install",
"test": "jest",
"test:update": "jest --updateSnapshot",
"test:watch": "jest --watch"
},
"devDependencies": {
Expand All @@ -41,7 +42,7 @@
"lib": "lib"
},
"dependencies": {
"adhan-extended": "^5.0.2",
"adhan-extended": "^6.1.0",
"luxon": "^3.3.0"
}
}
10 changes: 9 additions & 1 deletion src/adhan/calculate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-case-declarations */
import {
CalculationMethod,
Coordinates,
Expand Down Expand Up @@ -62,6 +63,13 @@ const getMethodFromShortName = (shortName: string) => {
return gaiae;
case 'muis':
return CalculationMethod.Singapore();
case 'algeria':
const algeria = CalculationMethod.Other();
algeria.fajrAngle = 18;
algeria.ishaAngle = 17;
algeria.methodAdjustments.sunset = 3;
algeria.methodAdjustments.maghrib = 3;
return algeria;

default:
return CalculationMethod.MuslimWorldLeague();
Expand Down Expand Up @@ -115,7 +123,7 @@ export function calculateAdhan(
const coordinates = new Coordinates(coords.latitude, coords.longitude);
const params = getCalculationParams(method, asrMethod, extras);

const timezone = date.zoneName; //ref: https://github.com/batoulapps/adhan-js#prayer-times
const timezone = date.zoneName || 'UTC'; //ref: https://github.com/batoulapps/adhan-js#prayer-times
const calculated = new PrayerTimes(coordinates, date.toJSDate(), params);
return {
fajr: DateTime.fromJSDate(calculated.fajr).setZone(timezone),
Expand Down
16 changes: 8 additions & 8 deletions src/adhan/calculation-methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ describe('calculatePrayerTimes', () => {
},
timezone: 'Europe/London',
calculationMethod: 'MoonsightingCommittee',
asrCalculation: 'hanafi',
asrCalculation: 'Hanafi',
highLatitudeRule: 'middleofthenight',
shafaq: 'general',
midnightMethod: 'Standard',
midnightMethod: 'SunsetToSunrise',
},
makkah: {
location: {
Expand All @@ -28,8 +28,8 @@ describe('calculatePrayerTimes', () => {
},
timezone: 'Asia/Riyadh',
calculationMethod: 'UmmAlQura',
asrCalculation: 'shafi',
midnightMethod: 'Standard',
asrCalculation: 'Standard',
midnightMethod: 'SunsetToSunrise',
highLatitudeRule: 'middleofthenight',
},
dubai: {
Expand All @@ -39,9 +39,9 @@ describe('calculatePrayerTimes', () => {
},
timezone: 'Asia/Dubai',
calculationMethod: 'Dubai',
asrCalculation: 'shafi',
asrCalculation: 'Standard',
highLatitudeRule: 'middleofthenight',
midnightMethod: 'Standard',
midnightMethod: 'SunsetToSunrise',
},
turkey: {
location: {
Expand All @@ -50,9 +50,9 @@ describe('calculatePrayerTimes', () => {
},
timezone: 'Europe/Istanbul',
calculationMethod: 'Turkey',
asrCalculation: 'shafi',
asrCalculation: 'Standard',
highLatitudeRule: 'middleofthenight',
midnightMethod: 'Standard',
midnightMethod: 'SunsetToSunrise',
},
};

Expand Down
53 changes: 47 additions & 6 deletions src/adhan/calculation-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,27 @@ import {
CalculationSettings,
CalculationMethodEntry,
PrayerTimesOptions,
CalculationMethodKey,
AsrCalculationType,
} from './types';
import { DateTime } from 'luxon';
import { PrayerAndSunnahTimes } from './prayer-and-sunnah-times';

export const CalculationMethods: Record<string, CalculationMethodEntry> = {
export const CalculationMethods: Record<
CalculationMethodKey,
CalculationMethodEntry
> = {
Custom: {
calculationKey: 'Custom',
label: 'Custom',
info: 'Sets a Fajr angle of 0 and an Isha angle of 0.' as const,
get: CalculationMethod.Other,
},

Algeria: {
calculationKey: 'Algeria',
label: 'Ministry of Religious Affairs and Wakfs, Algeria',
otherLabel: 'Ministry of Religious Affairs and Wakfs',
info: 'Uses Fajr angle of 18, Isha angle of 17, + 3min maghrib',
get: () => {
const params = new CalculationParameters('Other', 18.0, 17.0);
Expand All @@ -39,26 +47,31 @@ export const CalculationMethods: Record<string, CalculationMethodEntry> = {
},

Brunei: {
calculationKey: 'Brunei',
label: 'Kementrian Hal Ehwal Ugama (Brunei Darussalam)',
otherLabel: 'Brunei Darussalam',
info: 'Uses Fajr angle of 20 and Isha angle of 18',
get: () => new CalculationParameters('Other', 20.0, 18.0),
},

Dubai: {
calculationKey: 'Dubai',
label: 'The Gulf Region (Dubai)',
info: 'Uses Fajr and Isha angles of 18.2 degrees.',
url: 'https://www.awqaf.gov.ae/en/Pages/PrayerTimes.aspx',
get: CalculationMethod.Dubai,
},

Egyptian: {
calculationKey: 'Egyptian',
label: 'Egyptian General Survey Authority',
info: 'Uses Fajr angle of 19.5 and an Isha angle of 17.5' as const,
get: CalculationMethod.Egyptian,
region: 'Africa, Syria, Iraq, Lebanon, Malaysia, Parts of the USA' as const,
},

France: {
calculationKey: 'France',
label: 'Union Organization Islamic de France',
info: 'Uses a Fajr angle of 12 and an Isha angle of 12 by default but by setting alternativeCalculation to 15 or 18 it will updated accordingly.',
region: 'France region' as const,
Expand All @@ -81,71 +94,86 @@ export const CalculationMethods: Record<string, CalculationMethodEntry> = {
},

Gulf: {
calculationKey: 'Gulf',
label: 'Gulf region',
info: 'Modified version of Umm al-Qura that uses a Fajr angle of 19.5.',
get: () => new CalculationParameters('Other', 19.5, undefined, 90),
},

Jafari: {
calculationKey: 'Jafari',
label: 'Shia Ithna Ashari, Leva Institute, Qum',
otherLabel: 'Leva Institute, Qum',
info: 'Uses Fajr angle of 16, Maghrib angle of 4 and Isha angle of 14',
get: () => new CalculationParameters('Other', 16.0, 14.0, 0, 4.0),
},

Karachi: {
calculationKey: 'Karachi',
label: 'University of Islamic Sciences, Karachi',
otherLabel: 'University of Islamic Sciences',
info: 'Uses Fajr angle of 18 and an Isha angle of 18' as const,
get: CalculationMethod.Karachi,
region:
'Pakistan, Bangladesh, India, Afghanistan, Parts of Europe' as const,
},

Kemenag: {
Indonesia: {
calculationKey: 'Indonesia',
label: 'Kementrian Agama Republik Indonesia (KEMENAG)',
otherLabel: 'Kementrian Agama Republik Indonesia',
info: 'Uses Fajr angle of 20.0 and Isha angle of 18',
get: () => new CalculationParameters('Other', 20.0, 18.0),
},

Kuwait: {
calculationKey: 'Kuwait',
label: 'Kuwait',
info: 'Uses a Fajr angle of 18 and an Isha angle of 17.5',
get: CalculationMethod.Kuwait,
},

MoonsightingCommittee: {
calculationKey: 'MoonsightingCommittee',
label: 'Moonsighting Committee',
info: 'Uses a Fajr angle of 18 and an Isha angle of 18. Also uses seasonal adjustment values.' as const,
get: CalculationMethod.MoonsightingCommittee,
region: 'UK',
},

MuslimWorldLeague: {
calculationKey: 'MuslimWorldLeague',
label: 'Muslim World League',
info: 'Uses Fajr angle of 18 and an Isha angle of 17' as const,
get: CalculationMethod.MuslimWorldLeague,
region: 'Europe, The Far East, Parts of the USA',
},

NorthAmerica: {
IslamicSocietyOfNorthAmerica: {
calculationKey: 'IslamicSocietyOfNorthAmerica',
label: 'Islamic Society of North America - ISNA',
info: 'Uses a Fajr angle of 15 and an Isha angle of 15.' as const,
region: 'Parts of the USA, Canada, Parts of the UK' as const,
get: CalculationMethod.NorthAmerica,
},

Qatar: {
calculationKey: 'Qatar',
label: 'Qatar',
info: 'Modified version of Umm al-Qura that uses a Fajr angle of 18.',
url: 'https://www.qatarch.com/home',
get: CalculationMethod.Qatar,
},

Russia: {
calculationKey: 'Russia',
label: 'Spiritual Administration of Muslims of Russia',
info: 'Uses a Fajr angle of 16 and an Isha angle of 15.',
get: () => new CalculationParameters('Other', 16.0, 15.0),
},

Singapore: {
calculationKey: 'Singapore',
label: 'Singapore',
info: 'Uses a Fajr angle of 20 and an Isha angle of 18' as const,
get: CalculationMethod.Singapore,
Expand All @@ -154,12 +182,21 @@ export const CalculationMethods: Record<string, CalculationMethodEntry> = {
},

Tehran: {
calculationKey: 'Tehran',
label: 'Shia, Institute of Geophysics, University of Tehran',
info: 'Uses Fajr angle of 17.7, Maghrib angle of 4.5 and Isha angle of 14',
get: CalculationMethod.Tehran,
},

Tunisia: {
calculationKey: 'Tunisia',
label: 'Ministry of Religious Affairs of Tunisia',
info: 'Uses Fajr angle of 18 and Isha angle of 18',
get: () => new CalculationParameters('Other', 18.0, 18.0),
},

Turkey: {
calculationKey: 'Turkey',
label: 'Presidency of Religious Affairs, Turkey',
info: 'Uses a Fajr angle of 18 and an Isha angle of 17.',
url: 'https://kurul.diyanet.gov.tr/Karar-Mutalaa-Cevap/4093/45-enlemin-otesinde-namaz-vakitleri',
Expand Down Expand Up @@ -200,9 +237,10 @@ export const CalculationMethods: Record<string, CalculationMethodEntry> = {
prayerTimes.isha &&
prayerTimes.maghrib &&
prayerTimes.sunrise &&
prayerTimes.dateTime.monthLong &&
monthsBetween.includes(prayerTimes.dateTime.monthLong)
) {
let intervalTime =
const intervalTime =
prayerTimes.isha.diff(prayerTimes.maghrib).as('milliseconds') +
10 * 60 * 1000;

Expand All @@ -215,6 +253,7 @@ export const CalculationMethods: Record<string, CalculationMethodEntry> = {
},

UmmAlQura: {
calculationKey: 'UmmAlQura',
label: 'Umm al-Qura University, Makkah',
info: 'Uses a Fajr angle of 18.5 and an Isha interval of 90 minutes.\nNote: You should add a +30 minute custom adjustment of Isha during Ramadan.' as const,
url: 'https://www.ummulqura.org.sa/Index.aspx' as const,
Expand Down Expand Up @@ -346,9 +385,11 @@ function setHighLatitudeRule(

function setMadhab(
prayerTimeOptions: PrayerTimesOptions,
asrCalcSetting: typeof Madhab[keyof typeof Madhab] = Madhab.Shafi
asrCalcSetting: AsrCalculationType = 'Standard'
) {
prayerTimeOptions.calculationParameters.madhab = asrCalcSetting;
const type =
asrCalcSetting.toLowerCase() === 'hanafi' ? Madhab.Hanafi : Madhab.Shafi;
prayerTimeOptions.calculationParameters.madhab = type;
}

function setShafaq(
Expand Down
4 changes: 2 additions & 2 deletions src/adhan/prayer-and-sunnah-times.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { DateTime } from 'luxon';
import {
IAdhanCalculatedType,
PrayerTimesOptions,
formatOptions,
FormatOptions,
} from './types';
import { ValueOf } from 'adhan-extended/lib/types/TypeUtils';

Expand Down Expand Up @@ -148,7 +148,7 @@ export class PrayerAndSunnahTimes {
return this.prayerTimes.nextPrayer(date.toJSDate());
}

format(options: formatOptions): IAdhanCalculatedType {
format(options: FormatOptions): IAdhanCalculatedType {
const timezone = options.timezone || 'UTC';
const formatString = options.use24HourFormat ? 'HH:mm' : 'h:mm a';

Expand Down
Loading

0 comments on commit bfe5960

Please sign in to comment.