Packages

Calculating Azan times for a given location

Current section

4 Versions

Jump to

Compare versions

11 files changed
+94 additions
-63 deletions
  @@ -1,6 +1,8 @@
1 + [![Coverage Status](https://coveralls.io/repos/github/drselump14/azan_ex/badge.svg?branch=feature/add_livebook_usage)](https://coveralls.io/github/drselump14/azan_ex?branch=feature/add_livebook_usage)
2 +
1 3 # Azan
2 4
3 - **TODO: Add description**
5 + Calculate Azan for given time & location
4 6
5 7 ## Installation
6 8
  @@ -15,15 +17,13 @@ def deps do
15 17 end
16 18 ```
17 19
18 - Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
19 - and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
20 - be found at <https://hexdocs.pm/azan_ex>.
20 + The docs be found at <https://hexdocs.pm/azan_ex>.
21 21
22 22 ## Usage
23 23
24 24 ```elixir
25 25 date = DateTime.utc_now() |> DateTime.to_date()
26 - coordinate = %Azan.Coordinate{latitude: 35.671494 , longitude: 139.901810}
26 + {:ok, coordinate } = Azan.Coordinate.new(latitude: 35.671494 , longitude: 139.901810)
27 27 params = Azan.CalculationMethod.moonsighting_committee()
28 28
29 29 prayer_time = coordinate |> Azan.PrayerTime.find(date, params)
  @@ -38,3 +38,9 @@ be found at <https://hexdocs.pm/azan_ex>.
38 38 sunset: ~U[2022-10-01 08:25:00Z]
39 39 }
40 40 ```
41 +
42 + or try using livebook
43 +
44 + ```bash
45 + livebook server USAGE.livemd
46 + ```
  @@ -21,16 +21,16 @@
21 21 {<<"links">>,[{<<"GitHub">>,<<"https://github.com/drselump14/azan_ex">>}]}.
22 22 {<<"name">>,<<"azan_ex">>}.
23 23 {<<"requirements">>,
24 - [[{<<"app">>,<<"astro">>},
25 - {<<"name">>,<<"astro">>},
26 - {<<"optional">>,false},
27 - {<<"repository">>,<<"hexpm">>},
28 - {<<"requirement">>,<<"~> 0.9.2">>}],
29 - [{<<"app">>,<<"decimal">>},
24 + [[{<<"app">>,<<"decimal">>},
30 25 {<<"name">>,<<"decimal">>},
31 26 {<<"optional">>,false},
32 27 {<<"repository">>,<<"hexpm">>},
33 28 {<<"requirement">>,<<"~> 2.0">>}],
29 + [{<<"app">>,<<"domo">>},
30 + {<<"name">>,<<"domo">>},
31 + {<<"optional">>,false},
32 + {<<"repository">>,<<"hexpm">>},
33 + {<<"requirement">>,<<"~> 1.5.10">>}],
34 34 [{<<"app">>,<<"ex_machina">>},
35 35 {<<"name">>,<<"ex_machina">>},
36 36 {<<"optional">>,false},
  @@ -51,4 +51,4 @@
51 51 {<<"optional">>,false},
52 52 {<<"repository">>,<<"hexpm">>},
53 53 {<<"requirement">>,<<"~> 0.3.0">>}]]}.
54 - {<<"version">>,<<"0.1.0">>}.
54 + {<<"version">>,<<"0.2.0">>}.
  @@ -173,7 +173,7 @@ defmodule Azan.Astronomical do
173 173 if year |> Timex.is_leap?(), do: 173, else: 172
174 174 end
175 175
176 - @spec days_since_solstice(integer(), integer(), float()) :: pos_integer()
176 + @spec days_since_solstice(pos_integer(), pos_integer(), float()) :: integer()
177 177 def days_since_solstice(day_of_year, year, latitude) when latitude >= 0 do
178 178 days_since_solstice = day_of_year + @northern_offset
179 179 days_in_year = year |> DateUtils.days_in_year()
  @@ -8,8 +8,8 @@ defmodule Azan.CalculationMethod do
8 8 def muslim_world_league do
9 9 %CalculationParameter{
10 10 method: :muslim_world_league,
11 - fajr_angle: 18,
12 - isha_angle: 17
11 + fajr_angle: 18.0,
12 + isha_angle: 17.0
13 13 }
14 14 |> CalculationParameter.adjust_by_method(:dhuhr, 1)
15 15 end
  @@ -26,8 +26,8 @@ defmodule Azan.CalculationMethod do
26 26 def karachi do
27 27 %CalculationParameter{
28 28 method: :karachi,
29 - fajr_angle: 18,
30 - isha_angle: 18
29 + fajr_angle: 18.0,
30 + isha_angle: 18.0
31 31 }
32 32 |> CalculationParameter.adjust_by_method(:dhuhr, 1)
33 33 end
  @@ -56,8 +56,8 @@ defmodule Azan.CalculationMethod do
56 56 def moonsighting_committee do
57 57 params = %CalculationParameter{
58 58 method: :moonsighting_committee,
59 - fajr_angle: 18,
60 - isha_angle: 18
59 + fajr_angle: 18.0,
60 + isha_angle: 18.0
61 61 }
62 62
63 63 params
  @@ -77,7 +77,7 @@ defmodule Azan.CalculationMethod do
77 77 def kuwait do
78 78 %CalculationParameter{
79 79 method: :kuwait,
80 - fajr_angle: 18,
80 + fajr_angle: 18.0,
81 81 isha_angle: 17.5
82 82 }
83 83 end
  @@ -85,7 +85,7 @@ defmodule Azan.CalculationMethod do
85 85 def qatar do
86 86 %CalculationParameter{
87 87 method: :qatar,
88 - fajr_angle: 18,
88 + fajr_angle: 18.0,
89 89 isha_angle: 0,
90 90 isha_interval: 90
91 91 }
  @@ -94,8 +94,8 @@ defmodule Azan.CalculationMethod do
94 94 def singapore do
95 95 %CalculationParameter{
96 96 method: :singapore,
97 - fajr_angle: 20,
98 - isha_angle: 18,
97 + fajr_angle: 20.0,
98 + isha_angle: 18.0,
99 99 rounding: :up
100 100 }
101 101 |> CalculationParameter.adjust_by_method(:dhuhr, 1)
  @@ -105,7 +105,7 @@ defmodule Azan.CalculationMethod do
105 105 %CalculationParameter{
106 106 method: :tehran,
107 107 fajr_angle: 17.7,
108 - isha_angle: 14,
108 + isha_angle: 14.0,
109 109 isha_interval: 4
110 110 }
111 111 end
  @@ -113,8 +113,8 @@ defmodule Azan.CalculationMethod do
113 113 def turkey do
114 114 %CalculationParameter{
115 115 method: :turkey,
116 - fajr_angle: 18,
117 - isha_angle: 17
116 + fajr_angle: 18.0,
117 + isha_angle: 17.0
118 118 }
119 119 |> CalculationParameter.adjust_by_method(:sunrise, -7)
120 120 |> CalculationParameter.adjust_by_method(:dhuhr, 5)
  @@ -3,13 +3,14 @@ defmodule Azan.CalculationParameter do
3 3 Documentation for `CalculationParameter`.
4 4 """
5 5 use TypedStruct
6 + use Domo
6 7
7 8 typedstruct do
8 9 field :method, atom(), default: :other
9 - field :fajr_angle, float(), default: 0
10 - field :isha_angle, float(), default: 0
10 + field :fajr_angle, float(), default: 0.0
11 + field :isha_angle, float(), default: 0.0
11 12 field :isha_interval, integer(), default: 0
12 - field :maghrib_angle, float(), default: 0
13 + field :maghrib_angle, float(), default: 0.0
13 14
14 15 field :method_adjustments, map(),
15 16 default: %{fajr: 0, sunrise: 0, dhuhr: 0, asr: 0, maghrib: 0, isha: 0}
Loading more files…