Skip to content

Commit

Permalink
Merge pull request #17 from yasn77/issues/16/include_date
Browse files Browse the repository at this point in the history
Include date output
  • Loading branch information
uchagani authored Jul 19, 2022
2 parents 67dc7c2 + c03d0b2 commit 480e02f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
29 changes: 27 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ midnightMode = "jafari"
latitudeAdjustmentMethod = "one seventh"
# If tune = True, then you can tune the timings by adding the tune parameter
# (denoting addition / substraction in minutes)
# Please NOTE that tuning one prayer will not change another.
# Please NOTE that tuning one prayer will not change another.
# So adding 3 mins to Maghrib will NOT automatically add 3 mins to Isha
tune = False
imsak_tune = 0
Expand Down Expand Up @@ -63,5 +63,30 @@ times = calc.fetch_prayer_times()
the `fetch_prayer_times` method will return a dict similar to:

```python
{'Fajr': '05:31', 'Sunrise': '06:53', 'Dhuhr': '11:38', 'Asr': '14:03', 'Sunset': '16:22', 'Maghrib': '16:22', 'Isha': '17:44', 'Imsak': '05:21', 'Midnight': '23:38'}
{'Fajr': '05:31',
'Sunrise': '06:53',
'Dhuhr': '11:38',
'Asr': '14:03',
'Sunset': '16:22',
'Maghrib': '16:22',
'Isha': '17:44',
'Imsak': '05:21',
'Midnight': '22:57',
'date': {'readable': '26 Nov 2018',
'timestamp': '1543276800',
'hijri': {'date': '17-03-1440',
'format': 'DD-MM-YYYY',
'day': '17',
'weekday': {'en': 'Al Athnayn', 'ar': 'الاثنين'},
'month': {'number': 3, 'en': 'Rabīʿ al-awwal', 'ar': 'رَبيع الأوّل'},
'year': '1440',
'designation': {'abbreviated': 'AH', 'expanded': 'Anno Hegirae'},
'holidays': []},
'gregorian': {'date': '26-11-2018',
'format': 'DD-MM-YYYY',
'day': '26',
'weekday': {'en': 'Monday'},
'month': {'number': 11, 'en': 'November'},
'year': '2018',
'designation': {'abbreviated': 'AD', 'expanded': 'Anno Domini'}}}}
```
9 changes: 6 additions & 3 deletions prayer_times_calculator/pray_times_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class PrayerTimesCalculator:

API_URL = "http://api.aladhan.com/timings"
API_URL = "http://api.aladhan.com/v1/timings"

CALCULATION_METHODS = {
"jafari": 0,
Expand Down Expand Up @@ -98,7 +98,7 @@ def __init__(
else:
self._tune = False

if self._calculation_method == 99:
if self._calculation_method == 99:
self.custom_method(fajr_angle, maghrib_angle, isha_angle)
else: self._method_settings = False

Expand Down Expand Up @@ -136,4 +136,7 @@ def fetch_prayer_times(self):
if not response.status_code == 200:
raise InvalidResponseError(f"\nUnable to retrive prayer times. Url: {url}")

return response.json()["data"]["timings"]
resp = response.json()["data"]["timings"]
resp["date"] = response.json()["data"]["date"]

return resp

0 comments on commit 480e02f

Please sign in to comment.