Ejemplo n.º 1
0
/**
 * itl_prayer_getPrayerTimes:
 *
 * @prayer: (in): an #ItlPrayer
 * @cdate: (in): Date for which to calculate prayer times
 *
 * This function calculates prayer times for the given date
 *
 * Return value: (transfer full) (element-type GLib.DateTime): 6 prayer times from Fajr till Isha'
 */
GList *
itl_prayer_getPrayerTimes (ItlPrayer *prayer, GDate *cdate)
{
  Date ITLDate;
  GDateTime *fajr, *shurooq, *dhuhr, *asr, *maghrib, *isha;
  GList *Prayers=NULL;
  Prayer ITLPrayer[6];

  g_return_val_if_fail (GOBJECT_IS_PRAYER (prayer), 0);

  g_object_ref (prayer);

  ITLDate.day = g_date_get_day(cdate);
  ITLDate.month = g_date_get_month(cdate);
  ITLDate.year = g_date_get_year(cdate);

  getPrayerTimes (&prayer->priv->loc, &prayer->priv->method, &ITLDate,
                  ITLPrayer);

  fajr = g_date_time_new_local(ITLDate.year, ITLDate.month, ITLDate.day,
                               ITLPrayer[0].hour, ITLPrayer[0].minute,
                               ITLPrayer[0].second);
  shurooq = g_date_time_new_local(ITLDate.year, ITLDate.month, ITLDate.day,
                                  ITLPrayer[1].hour, ITLPrayer[1].minute,
                                  ITLPrayer[1].second);
  dhuhr = g_date_time_new_local(ITLDate.year, ITLDate.month, ITLDate.day,
                                ITLPrayer[2].hour, ITLPrayer[2].minute,
                                ITLPrayer[2].second);
  asr = g_date_time_new_local(ITLDate.year, ITLDate.month, ITLDate.day,
                              ITLPrayer[3].hour, ITLPrayer[3].minute,
                              ITLPrayer[3].second);
  maghrib = g_date_time_new_local(ITLDate.year, ITLDate.month, ITLDate.day,
                                  ITLPrayer[4].hour, ITLPrayer[4].minute,
                                  ITLPrayer[4].second);
  isha = g_date_time_new_local(ITLDate.year, ITLDate.month, ITLDate.day,
                               ITLPrayer[5].hour, ITLPrayer[5].minute,
                               ITLPrayer[5].second);

  Prayers = g_list_append(Prayers, fajr);
  Prayers = g_list_append(Prayers, shurooq);
  Prayers = g_list_append(Prayers, dhuhr);
  Prayers = g_list_append(Prayers, asr);
  Prayers = g_list_append(Prayers, maghrib);
  Prayers = g_list_append(Prayers, isha);

  g_object_unref (prayer);
  return(Prayers);
}
Ejemplo n.º 2
0
static void displayTimes(double lat, double lon, char *cityName, int day, int month, int year, int gmtDiff, int dst, int method)
{
    int i, deg, min;
    double sec;
    const char symb = (char)0x00B0;
    double qibla;

    Location loc;
    Method conf;
    Date date;

    Prayer ptList[6];
    Prayer imsaak;
    Prayer nextImsaak;
    Prayer nextFajr;

    /* fill the Date structure */
    date.day = day;
    date.month = month;
    date.year = year;
    /* fill the location info. structure */
    loc.degreeLat = lat;
    loc.degreeLong = lon;
    loc.gmtDiff = gmtDiff;
    loc.dst = dst;
    loc.seaLevel = 0;
    loc.pressure = 1010;
    loc.temperature= 10;


    /* auto fill the method structure. Have a look at prayer.h for a
     * list of supported methods */
    getMethod(method, &conf);
    conf.round = 0;

    /* Call the main function to fill the Prayer times array of
     * structures */
    getPrayerTimes (&loc, &conf, &date, ptList);

    /* Call functions for other prayer times and qibla */
    getImsaak (&loc, &conf, &date, &imsaak);
    getNextDayFajr (&loc, &conf, &date, &nextFajr);
    getNextDayImsaak (&loc, &conf, &date, &nextImsaak);
    qibla = getNorthQibla(&loc);


    /* Show the results */
    printf ("\nPrayer schedule for: %s on %2d/%2d/%4d\n", cityName,
        date.day, date.month, date.year);

    decimal2Dms (loc.degreeLat, &deg, &min, &sec);
    printf("\nLatitude\t=  %d%c %2d\' %4.1f\" %c", abs (deg), symb, abs (min),
       fabs (sec), (loc.degreeLat>=0) ? 'N' : 'S');

    decimal2Dms (loc.degreeLong, &deg, &min, &sec);
    printf ("\nLongitude\t=  %d%c %d\' %4.1f\" %c", abs (deg), symb, abs (min),
        fabs (sec), (loc.degreeLong>=0) ? 'E' : 'W');

    decimal2Dms (qibla, &deg, &min, &sec);
    printf("\nQibla\t\t=  %d%c %d\' %4.1f\" %c of true North\n", abs (deg), symb,
       abs (min), fabs (sec), (qibla>=0) ? 'W' : 'E');

    printf ("\n\n");

    for (i = 0; i < 6; i++)
    printf (" %3d:%02d:%02d%c", ptList[i].hour, ptList[i].minute, ptList[i].second,
        (ptList[i].isExtreme) ? '*' : ' ' );

    printf ("\n\n");
    printf("Tomorrow's Fajr:\t%3d:%02d\n", nextFajr.hour, nextFajr.minute);
    printf("Tomorrow's Imsaak:\t%3d:%02d\n", nextImsaak.hour, nextImsaak.minute);
    printf("Today's Imsaak:\t\t%3d:%02d\n\n", imsaak.hour, imsaak.minute);   
}