Skip to content

Commit

Permalink
Merge pull request #89 from batoulapps/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
z3bi authored Mar 14, 2022
2 parents 83c7c90 + 31cdd79 commit 457e723
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13.0
5 changes: 1 addition & 4 deletions Adhan.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Adhan.js.map

Large diffs are not rendered by default.

22 changes: 12 additions & 10 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,25 @@

const coordinates = new adhan.Coordinates(66.7222444, 17.7189);
const params = adhan.CalculationMethod.MuslimWorldLeague();
const date = new Date('2020-06-21 21:55')
params.polarCircleResolution = adhan.PolarCircleResolution.AqrabYaum;
params.highLatitudeRule = adhan.HighLatitudeRule.SeventhOfTheNight;
const date = new Date(2020, 05, 21);

var prayerTimes = new adhan.PrayerTimes(coordinates, date, params);

var sunnahTimes = new adhan.SunnahTimes(prayerTimes);

document.write('Raleigh, NC - Muslim World League\n');
document.write(`Prayer times for ${moment(date).format('MMMM DD, YYYY')}\n`);
document.write(`Fajr: ${moment(prayerTimes.fajr).tz('America/New_York').format('h:mm A')}\n`);
document.write(`Sunrise: ${moment(prayerTimes.sunrise).tz('America/New_York').format('h:mm A')}\n`);
document.write(`Dhuhr: ${moment(prayerTimes.dhuhr).tz('America/New_York').format('h:mm A')}\n`);
document.write(`Asr: ${moment(prayerTimes.asr).tz('America/New_York').format('h:mm A')}\n`);
document.write(`Maghrib: ${moment(prayerTimes.maghrib).tz('America/New_York').format('h:mm A')}\n`);
document.write(`Isha: ${moment(prayerTimes.isha).tz('America/New_York').format('h:mm A')}\n`);

document.write(`middle of the night: ${moment(sunnahTimes.middleOfTheNight).tz('America/New_York').format('h:mm A')}\n`);
document.write(`last third of the night: ${moment(sunnahTimes.lastThirdOfTheNight).tz('America/New_York').format('h:mm A')}\n\n`);
document.write(`Fajr: ${moment(prayerTimes.fajr).tz('Europe/Stockholm').format('MMMM DD, YYYY h:mm A')}\n`);
document.write(`Sunrise: ${moment(prayerTimes.sunrise).tz('Europe/Stockholm').format('MMMM DD, YYYY h:mm A')}\n`);
document.write(`Dhuhr: ${moment(prayerTimes.dhuhr).tz('Europe/Stockholm').format('MMMM DD, YYYY h:mm A')}\n`);
document.write(`Asr: ${moment(prayerTimes.asr).tz('Europe/Stockholm').format('MMMM DD, YYYY h:mm A')}\n`);
document.write(`Maghrib: ${moment(prayerTimes.maghrib).tz('Europe/Stockholm').format('MMMM DD, YYYY h:mm A')}\n`);
document.write(`Isha: ${moment(prayerTimes.isha).tz('Europe/Stockholm').format('MMMM DD, YYYY h:mm A')}\n`);

document.write(`middle of the night: ${moment(sunnahTimes.middleOfTheNight).tz('Europe/Stockholm').format('MMMM DD, YYYY h:mm A')}\n`);
document.write(`last third of the night: ${moment(sunnahTimes.lastThirdOfTheNight).tz('Europe/Stockholm').format('MMMM DD, YYYY h:mm A')}\n\n`);

document.write(`Current Prayer: ${prayerName(prayerTimes.currentPrayer())}\n\n`);

Expand Down
5 changes: 1 addition & 4 deletions src/PrayerTimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class PrayerTimes {
dhuhrTime = new TimeComponents(solarTime.transit).utcDate(date.getFullYear(), date.getMonth(), date.getDate());
sunriseTime = new TimeComponents(solarTime.sunrise).utcDate(date.getFullYear(), date.getMonth(), date.getDate());
let sunsetTime = new TimeComponents(solarTime.sunset).utcDate(date.getFullYear(), date.getMonth(), date.getDate());
let tomorrow = dateByAddingDays(date, 1);
const tomorrow = dateByAddingDays(date, 1);
let tomorrowSolarTime = new SolarTime(tomorrow, coordinates);

const polarCircleResolver = calculationParameters.polarCircleResolution;
Expand All @@ -43,10 +43,7 @@ export default class PrayerTimes {
&& polarCircleResolver !== PolarCircleResolution.Unresolved
) {
const resolved = polarCircleResolvedValues(polarCircleResolver, date, coordinates);
this.coordinates = resolved.coordinates;
this.date.setTime(resolved.date.getTime());
solarTime = resolved.solarTime;
tomorrow = resolved.tomorrow;
tomorrowSolarTime = resolved.tomorrowSolarTime;
const dateComponents = [date.getFullYear(), date.getMonth(), date.getDate()];

Expand Down
17 changes: 17 additions & 0 deletions test/adhan.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,5 +658,22 @@ describe('Polar circle resolution cases', () => {
expect(isValidDate(prayersTimes[prayerName])).toEqual(true);
});
});

test("calculating times for the polar circle", () => {
const coordinates = new adhan.Coordinates(66.7222444, 17.7189);
const params = adhan.CalculationMethod.MuslimWorldLeague();
params.polarCircleResolution = adhan.PolarCircleResolution.AqrabYaum;
params.highLatitudeRule = adhan.HighLatitudeRule.SeventhOfTheNight;
const date = new Date(2020, 5, 21);

const p = new adhan.PrayerTimes(coordinates, date, params);
expect(moment(p.fajr).tz("Europe/Stockholm").format("MMMM DD, YYYY h:mm A")).toBe("June 21, 2020 12:40 AM");
expect(moment(p.sunrise).tz("Europe/Stockholm").format("MMMM DD, YYYY h:mm A")).toBe("June 21, 2020 12:54 AM");
expect(moment(p.dhuhr).tz("Europe/Stockholm").format("MMMM DD, YYYY h:mm A")).toBe("June 21, 2020 12:55 PM");
expect(moment(p.asr).tz("Europe/Stockholm").format("MMMM DD, YYYY h:mm A")).toBe("June 21, 2020 5:49 PM");
expect(moment(p.maghrib).tz("Europe/Stockholm").format("MMMM DD, YYYY h:mm A")).toBe("June 21, 2020 11:36 PM");
expect(moment(p.isha).tz("Europe/Stockholm").format("MMMM DD, YYYY h:mm A")).toBe("June 21, 2020 11:51 PM");
});

});
});

0 comments on commit 457e723

Please sign in to comment.