Closed jd1378 closed 2 years ago
@jd1378 is your use case that you want to be able to display both Maghrib and sunset?
yes
I don't think it makes sense to add it to nextPrayer
since sunset isn't a prayer. Maghrib is the prayer time. We include sunrise
since thats when the prayer time for Fajr specifically ends. It might make more sense to export SolarTime
instead if you just want times of the sunset itself.
well its same usecase for maqrib in some places, it ends the prayer time for asr
But exporting SolarTime would be nice as well, but that would need exporting PolarCircleResolution
,TimeComponents
and DateUtils
to do the same thing as the lib is doing
I've already written a helper for myself, but I thought it would be nicer if the lib did it in the first place:
import {Coordinates, PolarCircleResolution} from 'adhan';
// @ts-ignore
import {isValidDate} from 'adhan/src/DateUtils';
// @ts-ignore
import {polarCircleResolvedValues} from 'adhan/src/PolarCircleResolution';
// @ts-ignore
import SolarTime from 'adhan/src/SolarTime';
// @ts-ignore
import TimeComponents from 'adhan/src/TimeComponents';
export function getSunset(
date: Date,
coordinates: Coordinates,
polarCircleResolver = PolarCircleResolution.Unresolved,
): Date {
let solarTime = new SolarTime(date, coordinates);
let sunsetTime = new TimeComponents(solarTime.sunset).utcDate(
date.getFullYear(),
date.getMonth(),
date.getDate(),
);
if (
!isValidDate(sunsetTime) &&
polarCircleResolver !== PolarCircleResolution.Unresolved
) {
const resolved = polarCircleResolvedValues(
polarCircleResolver,
date,
coordinates,
);
solarTime = resolved.solarTime;
const dateComponents = [
date.getFullYear(),
date.getMonth(),
date.getDate(),
];
sunsetTime = new TimeComponents(solarTime.sunset).utcDate(
...dateComponents,
);
}
return sunsetTime;
}
:tada: This issue has been resolved in version 4.4.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
Hi It would be good if the sunset time was also exported from prayerTimes and in the nextPrayer method
because in some calculation Maqrib prayer time is not same as sunset