Skip to content

Commit

Permalink
docs: added some useful information to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
khawarizmus committed Oct 6, 2023
1 parent 9caa22b commit c7605cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
17 changes: 14 additions & 3 deletions docs/config/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,23 @@ The calculation methods provided are based on our best capacity of research and
`prayers-call` offers the [`recommendMethod`](../api.md#functions) helper function, designed to suggest the most appropriate calculation methods for prayer times based on the country of a given location. The function accepts a [`CoordinatesObject`](../api.md#coordinatesobject) returns an array of recommended methods, ranked by best guess or by the number of methods commonly used in that specific country. If no match is found, the function returns `undefined`. Here's an example:"

```ts
import { recommendMethod } from 'prayers-call'
import { ReactiveCalculator, recommendMethod } from 'prayers-call'

const methods = recommendMethod({ latitude: 21.3891, longitude: 39.8579 }) // mekka coordinates
console.log(methods) // Output: ['UmmAlQura']
const makkaCoordinates = { latitude: 21.3891, longitude: 39.8579 }

const recommendedMethod = recommendMethod(makkaCoordinates)[0] // 'UmmAlQura'

const reactiveCalculator = new ReactiveCalculator({
latitude: makkaCoordinates.latitude,
longitude: makkaCoordinates.longitude,
method: recommendedMethod ? recommendedMethod : Methods.MUSLIM_WORLD_LEAGUE,
})
```

::: tip
While the `recommendMethod` function returns an array of recommended methods, the clculators expect one method only. If no match is found, the function returns `undefined`. in that case you can use methods like `MUSLIM_WORLD_LEAGUE`, `STANDARD` or even `UMM_AL_QURA` as a fallback.
:::

The following is a map projecting the recommended methods for each country. hover on a country to see the recommended methods.

<MethodsMap />
Expand Down
6 changes: 6 additions & 0 deletions docs/recipes/formatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The `Formatter` class in `prayers-call` provides a flexible way to format dates and times, including Islamic (Hijri) dates. It leverages the [`Intl.DateTimeFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) API for internationalization (I18n) and supports a variety of formatting options.

::: tip
By using the `Intl.DateTimeFormat`, `prayers-call` remove the need to use a separate library for internationalization (I18n) and date time formatting. This also means we are relying on the standard way of formatting dates and times in JavaScript, which is supported by all modern browsers and Node.js.

Of course you can use libraries like [date-fns](https://date-fns.org/) or [moment.js](https://momentjs.com/) to format the dates and times returned by `prayers-call`.
:::

## Initialization and Configuration

To begin using the `Formatter` class, you'll need to initialize it. While the class comes with a default configuration, you can customize it by passing an optional [`FormatterConfig`](../api.md#formatterconfig) object during initialization.
Expand Down
2 changes: 1 addition & 1 deletion docs/recipes/hijri.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Islamic calendars are usually categorized as bellow:
| SIGHTING_SA | `islamic-rgsa` | Based on moon sighting in the region of Saudi Arabia; Requested by Oracle. dates may vary. |

::: tip
The `Intl.DateTimeFormat` API support other calendars as well. to get a full list of supported calendars, you can use the `Intl.Locale.prototype.getCalendars()` method.
The `Intl.DateTimeFormat` API support calendars other then the islamic calendars as well. to get a full list of supported calendars, you can use the `Intl.Locale.prototype.getCalendars()` method.
:::

### Arabic Display of Dates
Expand Down

0 comments on commit c7605cc

Please sign in to comment.