UNPKG

salat-first

Version:

Islamic prayer times calculation with special support for Moroccan methods and Maliki madhab

50 lines (49 loc) 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ShadowMethod = void 0; exports.getShadowLengthMultiplier = getShadowLengthMultiplier; exports.calculateAsrAngle = calculateAsrAngle; const math_1 = require("./math"); /** * Shadow length calculation methods */ var ShadowMethod; (function (ShadowMethod) { /** * Shafi, Maliki, and Hanbali madhabs use this method * Asr time starts when shadow length equals object height plus shadow length at noon */ ShadowMethod["Standard"] = "standard"; /** * Hanafi madhab uses this method * Asr time starts when shadow length equals twice object height plus shadow length at noon */ ShadowMethod["Hanafi"] = "hanafi"; })(ShadowMethod || (exports.ShadowMethod = ShadowMethod = {})); /** * Calculates the shadow length for Asr prayer * @param method The shadow calculation method * @returns The shadow length multiplier */ function getShadowLengthMultiplier(method) { switch (method) { case ShadowMethod.Standard: return 1; case ShadowMethod.Hanafi: return 2; default: throw new Error(`Unknown shadow method: ${method}`); } } /** * Calculates the angle for Asr prayer based on shadow length * @param latitude The latitude in degrees * @param declination The solar declination in degrees * @param shadowLength The shadow length multiplier * @returns The angle in degrees */ function calculateAsrAngle(latitude, declination, shadowLength) { const tangent = Math.abs(latitude - declination); const inverse = shadowLength + Math.tan((0, math_1.degreesToRadians)(tangent)); return (0, math_1.radiansToDegrees)(Math.atan(1.0 / inverse)); }