// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static class approx_sun_coord {
//     double D;   /* Declination of the Sun */
//     double EqT; /* The Equation of Time */
//     double R;   /* The distance of the Sun from the Earth
//                in astronomical units (AU)  */
//     double SD;  /* The angular semidiameter of the Sun in degrees */
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static class date_t {
//     int year, month, day;
// 
//     /**
//      * @param day starts from 1
//      * @param month starts from 1, like the old ITL
//      */
//     date_t set(int day, int month, int year) {
//         this.year = year;
//         this.month = month;
//         this.day = day;
//         return this;
//     }
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static class location {
//     /* In original C: The struct members ordering guarantees that the compiler does
//      * not add any padding bytes when compiling for 64-bit machines */
// 
//     double longitude;   /* Observer's longitude */
//     double latitude;    /* Observer's latitude */
//     double altitude;    /* Observer's altitude in meters */
//     double timezone;    /* Observer's timezone (in hours) relative
//                               to Universal Coordinated Time (UTC) */
//     int daylight;    /* Daylight Savings Time (DST) Flag
//                               Set to 1 if DST is on, 0 otherwise */
//     AsrMethod asr_method;  /* Asr Method: Shafii or Hanafi */
//     CalcMethod calc_method; /* Fajr and Isha Calculation method */
//     ExtremeMethod extr_method; /* Extreme latitude method */
//     String name;    /* Observer's location name */
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// enum round_t {
//     UP, DOWN, NEAREST
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static final double KAABA_LATITUDE = (21.42249);
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static final double KAABA_LONGITUDE = (39.82620);
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static final double M_PI = (3.141592653589793);
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static final double ONE_MINUTE = (60.0 / 3600.0);


import static org.arabeyes.itl.newmethod.DefsModule.ONE_MINUTE;
import org.arabeyes.itl.newmethod.DefsModule.approx_sun_coord;
import org.arabeyes.itl.newmethod.DefsModule.date_t;
import org.arabeyes.itl.newmethod.DefsModule.location;
import org.arabeyes.itl.newmethod.DefsModule.round_t;
import static java.lang.Math.acos;
import static java.lang.Math.asin;
import static java.lang.Math.atan2;
import static java.lang.Math.ceil;
import static java.lang.Math.cos;
import static java.lang.Math.floor;
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;
import static java.lang.Math.tan;
import static org.arabeyes.itl.newmethod.DefsModule.KAABA_LATITUDE;
import static org.arabeyes.itl.newmethod.DefsModule.KAABA_LONGITUDE;
import static org.arabeyes.itl.newmethod.DefsModule.M_PI;
                rounding == round_t.NEAREST);

        t.julian_day = julian_day;
        f = floor(decimal_time);
        t.hour = (int) f;
        r = (decimal_time - f) * 60.0;
        switch (rounding) {
            case UP:
                t.minute = (int) (ceil(r));
                break;
            case DOWN:
                t.minute = (int) (floor(r));
                break;
            case NEAREST:
                t.minute = (int) (custom_round(r));
                break;
        }
    }

    /**
     * Compute the Qibla direction from North clockwise
     * using the Equation (1) given in references/qibla.pdf
     */
    static double get_qibla_direction(location loc) {
        double p1, p2, p3, qibla;

        assert (loc != null);

        p1 = sin(to_radians(KAABA_LONGITUDE - loc.longitude));
        p2 = cos(to_radians(loc.latitude)) *
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static class approx_sun_coord {
//     double D;   /* Declination of the Sun */
//     double EqT; /* The Equation of Time */
//     double R;   /* The distance of the Sun from the Earth
//                in astronomical units (AU)  */
//     double SD;  /* The angular semidiameter of the Sun in degrees */
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static class date_t {
//     int year, month, day;
// 
//     /**
//      * @param day starts from 1
//      * @param month starts from 1, like the old ITL
//      */
//     date_t set(int day, int month, int year) {
//         this.year = year;
//         this.month = month;
//         this.day = day;
//         return this;
//     }
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static class location {
//     /* In original C: The struct members ordering guarantees that the compiler does
//      * not add any padding bytes when compiling for 64-bit machines */
// 
//     double longitude;   /* Observer's longitude */
//     double latitude;    /* Observer's latitude */
//     double altitude;    /* Observer's altitude in meters */
//     double timezone;    /* Observer's timezone (in hours) relative
//                               to Universal Coordinated Time (UTC) */
//     int daylight;    /* Daylight Savings Time (DST) Flag
//                               Set to 1 if DST is on, 0 otherwise */
//     AsrMethod asr_method;  /* Asr Method: Shafii or Hanafi */
//     CalcMethod calc_method; /* Fajr and Isha Calculation method */
//     ExtremeMethod extr_method; /* Extreme latitude method */
//     String name;    /* Observer's location name */
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// enum round_t {
//     UP, DOWN, NEAREST
// }
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static final double KAABA_LATITUDE = (21.42249);
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static final double KAABA_LONGITUDE = (39.82620);
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static final double M_PI = (3.141592653589793);
// 
// Path: itl/src/main/java/org/arabeyes/itl/newmethod/DefsModule.java
// static final double ONE_MINUTE = (60.0 / 3600.0);


// Path: itl/src/main/java/org/arabeyes/itl/newmethod/PrayerModule.java
import static org.arabeyes.itl.newmethod.DefsModule.ONE_MINUTE;
import org.arabeyes.itl.newmethod.DefsModule.approx_sun_coord;
import org.arabeyes.itl.newmethod.DefsModule.date_t;
import org.arabeyes.itl.newmethod.DefsModule.location;
import org.arabeyes.itl.newmethod.DefsModule.round_t;
import static java.lang.Math.acos;
import static java.lang.Math.asin;
import static java.lang.Math.atan2;
import static java.lang.Math.ceil;
import static java.lang.Math.cos;
import static java.lang.Math.floor;
import static java.lang.Math.sin;
import static java.lang.Math.sqrt;
import static java.lang.Math.tan;
import static org.arabeyes.itl.newmethod.DefsModule.KAABA_LATITUDE;
import static org.arabeyes.itl.newmethod.DefsModule.KAABA_LONGITUDE;
import static org.arabeyes.itl.newmethod.DefsModule.M_PI;

                rounding == round_t.NEAREST);

        t.julian_day = julian_day;
        f = floor(decimal_time);
        t.hour = (int) f;
        r = (decimal_time - f) * 60.0;
        switch (rounding) {
            case UP:
                t.minute = (int) (ceil(r));
                break;
            case DOWN:
                t.minute = (int) (floor(r));
                break;
            case NEAREST:
                t.minute = (int) (custom_round(r));
                break;
        }
    }

    /**
     * Compute the Qibla direction from North clockwise
     * using the Equation (1) given in references/qibla.pdf
     */
    static double get_qibla_direction(location loc) {
        double p1, p2, p3, qibla;

        assert (loc != null);

        p1 = sin(to_radians(KAABA_LONGITUDE - loc.longitude));
        p2 = cos(to_radians(loc.latitude)) *
                tan(to_radians(KAABA_LATITUDE));