// 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;
        assert (dhuhr > 0.0);
        assert (loc != null);
        assert (coord != null);

        if (loc.extr_method == ExtremeMethod.NONE) {
            if (loc.calc_method.isha_type == IshaFlag.OFFSET) {
                /* Umm Al-Qura uses a fixed offset */
                isha = sunset + loc.calc_method.isha * ONE_MINUTE;
            } else {
                isha = dhuhr + T(loc.calc_method.isha,
                        loc.latitude,
                        coord.D);
            }
        } else {
            /* TODO: Extreme latitude */
            throw new UnsupportedOperationException("Extreme altitudes are not implemented yet!");
        }

        isha = normalize(isha, 24.0);
        return isha;
    }

    /**
     * Convert a given time in decimal format to
     * hh:mm format and store it in the given event struct.
     * The minutes part can be rounded up or down based on the
     * round flag
     */
    private static void conv_time_to_event(final int julian_day,
                                           final double decimal_time,
// 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;

        assert (dhuhr > 0.0);
        assert (loc != null);
        assert (coord != null);

        if (loc.extr_method == ExtremeMethod.NONE) {
            if (loc.calc_method.isha_type == IshaFlag.OFFSET) {
                /* Umm Al-Qura uses a fixed offset */
                isha = sunset + loc.calc_method.isha * ONE_MINUTE;
            } else {
                isha = dhuhr + T(loc.calc_method.isha,
                        loc.latitude,
                        coord.D);
            }
        } else {
            /* TODO: Extreme latitude */
            throw new UnsupportedOperationException("Extreme altitudes are not implemented yet!");
        }

        isha = normalize(isha, 24.0);
        return isha;
    }

    /**
     * Convert a given time in decimal format to
     * hh:mm format and store it in the given event struct.
     * The minutes part can be rounded up or down based on the
     * round flag
     */
    private static void conv_time_to_event(final int julian_day,
                                           final double decimal_time,
                                           final round_t rounding,