-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add typescript definitions, better enum raw values, removed use of va…
…r whenever possible
- Loading branch information
Showing
21 changed files
with
400 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
export as namespace adhan; | ||
|
||
export class PrayerTimes { | ||
constructor(coordinates: Coordinates, date: Date, params: CalculationParameters); | ||
|
||
fajr: Date; | ||
sunrise: Date; | ||
dhuhr: Date; | ||
asr: Date; | ||
maghrib: Date; | ||
isha: Date; | ||
|
||
timeForPrayer(prayer: Prayer): Date; | ||
currentPrayer(date?: Date): Prayer; | ||
nextPrayer(date?: Date): Prayer; | ||
} | ||
|
||
export class CalculationParameters { | ||
constructor(fajrAngle: number, ishaAngle: number, ishaInterval: number, methodName?: string) | ||
|
||
readonly method: string; | ||
fajrAngle: number; | ||
ishaAngle: number; | ||
ishaInterval: number; | ||
madhab: Madhab; | ||
highLatitudeRule: HighLatitudeRule; | ||
adjustments: PrayerAdjustments; | ||
} | ||
|
||
export interface PrayerAdjustments { | ||
fajr: number; | ||
sunrise: number; | ||
dhuhr: number; | ||
asr: number; | ||
maghrib: number; | ||
isha: number; | ||
} | ||
|
||
export namespace CalculationMethod { | ||
export function MuslimWorldLeague(): CalculationParameters; | ||
export function Egyptian(): CalculationParameters; | ||
export function Karachi(): CalculationParameters; | ||
export function UmmAlQura(): CalculationParameters; | ||
export function Dubai(): CalculationParameters; | ||
export function MoonsightingCommittee(): CalculationParameters; | ||
export function NorthAmerica(): CalculationParameters; | ||
export function Kuwait(): CalculationParameters; | ||
export function Qatar(): CalculationParameters; | ||
export function Singapore(): CalculationParameters; | ||
export function Other(): CalculationParameters; | ||
} | ||
|
||
export class Coordinates { | ||
constructor(longitude: number, latitude: number); | ||
longitude: number; | ||
latitude: number; | ||
} | ||
|
||
export class SunnahTimes { | ||
constructor(prayerTimes: PrayerTimes); | ||
|
||
middleOfTheNight: Date; | ||
lastThirdOfTheNight: Date; | ||
} | ||
|
||
export enum Madhab { | ||
Shafi, | ||
Hanafi | ||
} | ||
|
||
export enum Prayer { | ||
Fajr, | ||
Sunrise, | ||
Dhuhr, | ||
Asr, | ||
Maghrib, | ||
Isha, | ||
None | ||
} | ||
|
||
export enum HighLatitudeRule { | ||
MiddleOfTheNight, | ||
SeventhOfTheNight, | ||
TwilightAngle | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
## Upgrading from 1.0.1 to 2.0.0 | ||
Upgrading to 2.0.0 introduces breaking API changes. | ||
## Upgrading from 3.0.0 to 4.0.0 | ||
Upgrading to 4.0.0 introduces breaking API changes. | ||
|
||
JavaScript `Date` and `Number` prototypes are no longer patched by this library. | ||
The library should now be pure without any side effects. | ||
The `adhan.Date.formattedTime` convenience function is no longer provided by this library. | ||
These functions obscure the difficulty in dealing with Daylight Savings Time | ||
and other timezone issues. | ||
|
||
This means you can no longer depend on methods like `formattedTime` being directly accessible on the Date instance. For example, | ||
Instead you should use a timezone aware date formatting library like [moment](https://momentjs.com). | ||
|
||
**Before**: | ||
|
||
```js | ||
prayerTimes.fajr.formattedTime(); // no longer works | ||
adhan.Date.formattedTime(prayerTimes.fajr); // no longer available | ||
``` | ||
|
||
**After**: | ||
|
||
```js | ||
adhan.Date.formattedTime(prayerTimes.fajr); // works | ||
moment(prayerTimes.fajr).tz('America/New_York').format('h:mm A'); // Recommended method | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.