praytime-rs 1.0.1

Prayer Times Calculator - A Rust implementation of PrayTimes.org library
Documentation
# PrayTime - Prayer Times Calculator (Rust)

A Rust implementation of the PrayTimes.org library for calculating Islamic prayer times. This crate provides accurate prayer time calculations based on astronomical formulas and supports multiple calculation methods used around the world.

## Features

- **Multiple Calculation Methods**: Supports 10 different calculation methods including ISNA, MWL, Egypt, Makkah, Karachi, Tehran, Jafari, France, Russia, and Singapore
- **Flexible Location Support**: Works with latitude/longitude coordinates
- **Timezone Support**: Full timezone support using chrono-tz or UTC offset
- **Multiple Time Formats**: 24-hour, 12-hour with/without AM/PM, and Unix timestamps
- **High Latitude Adjustments**: Special handling for locations at high latitudes where normal calculations may not work
- **Customizable Parameters**: Tune individual prayer times, adjust calculation parameters
- **ASR Methods**: Support for both Standard and Hanafi ASR calculation methods
- **Serde Support**: Serialize and deserialize prayer times
- **Clean API**: Builder pattern for easy configuration

## Installation

Add this to your `Cargo.toml`:

```toml
[dependencies]
praytime-rs = "1.0.0"
```

## Quick Start

```rust
use praytime_rs::PrayTime;

let mut praytime = PrayTime::new("ISNA");
praytime.location(43.6532, -79.3832)  // Toronto coordinates
    .timezone("America/Toronto");

let times = praytime.get_times(None);
println!("Fajr: {}", times.fajr);
println!("Dhuhr: {}", times.dhuhr);
println!("Asr: {}", times.asr);
println!("Maghrib: {}", times.maghrib);
println!("Isha: {}", times.isha);
```

## Calculation Methods

| Method     | Description                                    | Fajr Angle | Isha Angle/Time |
|------------|------------------------------------------------|------------|-----------------|
| **ISNA**   | Islamic Society of North America               | 15°        | 15°             |
| **MWL**    | Muslim World League                            | 18°        | 17°             |
| **Egypt**  | Egyptian General Authority of Survey           | 19.5°      | 17.5°           |
| **Makkah** | Umm Al-Qura University, Makkah                 | 18.5°      | 90 min          |
| **Karachi**| University of Islamic Sciences, Karachi        | 18°        | 18°             |
| **Tehran** | Institute of Geophysics, University of Tehran  | 17.7°      | 4.5° + Jafari   |
| **Jafari** | Shia Ithna-Ashari (Jafari)                    | 16°        | 4° + Jafari     |
| **France** | France                                         | 12°        | 12°             |
| **Russia** | Russia                                         | 16°        | 15°             |
| **Singapore** | Singapore                                   | 20°        | 18°             |

## Advanced Usage

### Custom Date and Location

```rust
use praytime_rs::{PrayTime, TimeFormat};
use chrono::NaiveDate;

let mut praytime = PrayTime::new("ISNA");
praytime.location(21.4225, 39.8262)  // Makkah coordinates
    .timezone("Asia/Riyadh")
    .format(TimeFormat::Hour12);

let date = NaiveDate::from_ymd_opt(2024, 1, 1).unwrap();
let times = praytime.get_times(Some(date));
```

### Using UTC Offset

```rust
let mut praytime = PrayTime::new("MWL");
praytime.location(40.7128, -74.0060)  // New York coordinates
    .utc_offset(-300);  // -5 hours in minutes
```

### Hanafi ASR Method

```rust
use praytime_rs::{PrayTime, AsrMethod};

let mut praytime = PrayTime::new("ISNA");
praytime.location(43.6532, -79.3832)
    .asr_method(AsrMethod::Hanafi);
```

### High Latitude Adjustments

```rust
use praytime_rs::{PrayTime, HighLatitudeRule};

let mut praytime = PrayTime::new("ISNA");
praytime.location(59.3293, 18.0686)  // Stockholm coordinates
    .high_latitude_rule(HighLatitudeRule::NightMiddle);
```

### Time Adjustments (Tuning)

```rust
use praytime_rs::TuneAdjustments;

// Add 2 minutes to Fajr, subtract 1 minute from Isha
praytime.tune_with(TuneAdjustments {
    fajr: 2.0,
    sunrise: 0.0,
    dhuhr: 0.0,
    asr: 0.0,
    sunset: 0.0,
    maghrib: 0.0,
    isha: -1.0,
    midnight: 0.0,
});
```

### Different Time Formats

```rust
use praytime_rs::{TimeFormat, RoundingMethod};

praytime.format(TimeFormat::Hour12)
    .rounding(RoundingMethod::Nearest);
```

## API Reference

### Main Struct

- `PrayTime::new(method: &str)` - Create new instance with calculation method
- `location(lat: f64, lng: f64)` - Set coordinates
- `timezone(tz: &str)` - Set timezone (e.g., "America/Toronto")
- `utc_offset(minutes: i32)` - Set UTC offset in minutes
- `get_times(date: Option<NaiveDate>)` - Calculate prayer times

### Configuration Methods

- `format(format: TimeFormat)` - Set time format
- `rounding(method: RoundingMethod)` - Set rounding method
- `asr_method(method: AsrMethod)` - Set ASR calculation method
- `high_latitude_rule(rule: HighLatitudeRule)` - Set high latitude adjustment
- `tune_with(TuneAdjustments)` - Fine-tune individual prayer times

### Enums

#### TimeFormat
- `Hour24` - 24-hour format (default)
- `Hour12` - 12-hour with AM/PM
- `Hour12NoSuffix` - 12-hour without AM/PM
- `Timestamp` - Unix timestamp

#### RoundingMethod
- `Nearest` - Round to nearest minute (default)
- `Up` - Round up
- `Down` - Round down
- `None` - No rounding

#### AsrMethod
- `Standard` - Shafi, Maliki, Hanbali (default)
- `Hanafi` - Hanafi school

#### HighLatitudeRule
- `NightMiddle` - Middle of night (default)
- `OneSeventh` - 1/7th of night
- `AngleBased` - Angle-based method
- `None` - No adjustment

## Examples

Run the example to see the library in action:

```bash
cargo run --example basic_usage
```

## Testing

Run the test suite:

```bash
cargo test
```

## License

This project is licensed under the **Code Waqf License** (Lisensi Wakaf Kode) - a custom Islamic license that permits free use while prohibiting usage for activities that contradict Islamic principles.

The Code Waqf License template is available at: https://gitlab.com/GwNih/templat-lisensi-wakaf

See the [LICENSE](LICENSE.md) file for the complete license text.

## Credits

- Original JavaScript library: [PrayTimes.org]http://praytimes.org by Hamid Zarrabi-Zadeh
- Rust conversion: Gandi Wibowo

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Changelog

### Version 1.0.0
- Initial Rust implementation
- Full feature parity with JavaScript version 3.2
- Serde support for serialization
- Comprehensive test suite
- Multiple examples and documentation
- Licensed under Code Waqf License (Lisensi Wakaf Kode)