deno.land / x / prayers@v1.6.0 / src / Calculator.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { Coordinates, Prayer, Qibla } from 'adhan'import { BaseCalculator } from './Base'import type { CalculationsConfig } from './types/CalculationsConfig'import type { CoordinatesObject } from './types/Coordinates'import { PrayerNames, type PrayerNamesType, type TimeObject } from './types/TimeObject'import { dateByAddingMinutes } from './utils/DatesUtils'
export class StaticCalculator extends BaseCalculator { constructor(config: CalculationsConfig) { super(config) }
public getAllPrayerTimes(): TimeObject[] { return [ { name: Prayer.Fajr, time: this._prayerTimesCalculator.fajr, }, { name: Prayer.Sunrise, time: this._prayerTimesCalculator.sunrise, }, { name: Prayer.Dhuhr, time: this._prayerTimesCalculator.dhuhr, }, { name: Prayer.Asr, time: this._prayerTimesCalculator.asr, }, { name: Prayer.Maghrib, time: this._prayerTimesCalculator.maghrib, }, { name: Prayer.Isha, time: this._adjustForRamadan() ? dateByAddingMinutes(this._prayerTimesCalculator.isha, 30) : this._prayerTimesCalculator.isha, }, ] }
public getPrayerTime(prayer: PrayerNamesType): Date { // check if prayer is isha and needs to adjust return prayer === PrayerNames.ISHA && this._adjustForRamadan() ? // then add 30 minutes dateByAddingMinutes(this._prayerTimesCalculator.timeForPrayer(prayer)!, 30) : // else just return the prayer time this._prayerTimesCalculator.timeForPrayer(prayer)! }
public getMiddleOfTheNightTime(): TimeObject { return { name: 'middleOfTheNight', time: this._qiyamTimesCalculator.middleOfTheNight } }
public getLastThirdOfTheNightTime(): TimeObject { return { name: 'lastThirdOfTheNight', time: this._qiyamTimesCalculator.lastThirdOfTheNight } }
/** * Get the direction, in degrees from North, of the Qibla from a given set of coordinates. * @param Coordinates - optionally pass latitude and longitude values as an object * @returns value representing the direction in degrees from North. */ public getQiblaDirection( { latitude, longitude }: CoordinatesObject = { latitude: this._prayerConfig.latitude, longitude: this._prayerConfig.longitude, } ): number { const coordinates = new Coordinates(latitude, longitude) return Qibla(coordinates) }
public getCalculationOptions(): CalculationsConfig { return this._prayerConfig }
public setCalculationOptions(newConfig: Partial<CalculationsConfig>) { this._prayerConfig = Object.assign(this._prayerConfig, newConfig) this._initializer(this._prayerConfig) }}
prayers

Version Info

Tagged at
7 months ago