File azan.c changed (mode: 100644) (index bf3874b..30cf349) |
4 |
4 |
* print next pray left duration. |
* print next pray left duration. |
5 |
5 |
*/ |
*/ |
6 |
6 |
|
|
7 |
|
#include <stdio.h> |
|
|
7 |
|
#undef _POSIX_C_SOURCE |
|
8 |
|
#define _POSIX_C_SOURCE 200809L |
|
9 |
|
|
8 |
10 |
#include <time.h> |
#include <time.h> |
|
11 |
|
#include <stdio.h> |
|
12 |
|
#include <stdlib.h> |
9 |
13 |
#include <math.h> |
#include <math.h> |
10 |
14 |
#include <string.h> |
#include <string.h> |
|
15 |
|
#ifdef __unix__ |
|
16 |
|
#include <sys/types.h> |
|
17 |
|
#include <sys/stat.h> |
|
18 |
|
#endif |
11 |
19 |
|
|
12 |
20 |
#include "azan.h" |
#include "azan.h" |
13 |
21 |
#include "config.h" |
#include "config.h" |
|
... |
... |
convert_today_double_to_timet(double event_time) |
36 |
44 |
return converted; |
return converted; |
37 |
45 |
} |
} |
38 |
46 |
|
|
|
47 |
|
static char* |
|
48 |
|
convert_timet_to_str(time_t input_time) |
|
49 |
|
{ |
|
50 |
|
char* result; |
|
51 |
|
/* thie is */ |
|
52 |
|
// result = malloc((sizeof(char))*32); |
|
53 |
|
result = calloc(32, sizeof(char)); |
|
54 |
|
if (result == NULL) { |
|
55 |
|
printf("Error, allocating memory [ Line %d ]\n", __LINE__); |
|
56 |
|
exit(EXIT_FAILURE); |
|
57 |
|
} |
|
58 |
|
|
|
59 |
|
size_t max_result_char = 32; |
|
60 |
|
struct tm new_time = *localtime(&input_time); |
|
61 |
|
(void) snprintf(result, max_result_char, "%.2d:%.2d", |
|
62 |
|
new_time.tm_hour, new_time.tm_min); |
|
63 |
|
/* TEST */ |
|
64 |
|
/* printf("input time = %ld\n", input_time); */ |
|
65 |
|
/* printf("result = %s\n", result); */ |
|
66 |
|
return result; |
|
67 |
|
} |
|
68 |
|
|
|
69 |
|
static char* |
|
70 |
|
convert_sec_int_to_min_hour(int input_seconds) |
|
71 |
|
{ |
|
72 |
|
// static char result[32]; |
|
73 |
|
char* result; |
|
74 |
|
result = calloc(32, sizeof(char)); |
|
75 |
|
if (result == NULL) { |
|
76 |
|
printf("Error, allocating memory [ Line %d ]\n", __LINE__); |
|
77 |
|
exit(EXIT_FAILURE); |
|
78 |
|
} |
|
79 |
|
|
|
80 |
|
size_t max_result_char = 32; |
|
81 |
|
// int hours,minutes,seconds; |
|
82 |
|
int hours,minutes; |
|
83 |
|
int remainingSeconds; |
|
84 |
|
int secondsInHour = 60 * 60; |
|
85 |
|
int secondsInMinute = 60; |
|
86 |
|
hours = (input_seconds/secondsInHour); |
|
87 |
|
remainingSeconds = input_seconds - (hours * secondsInHour); |
|
88 |
|
minutes = remainingSeconds/secondsInMinute; |
|
89 |
|
(void)snprintf(result, max_result_char, "%.2d:%.2d",hours,minutes); |
|
90 |
|
return result; |
|
91 |
|
} |
|
92 |
|
|
39 |
93 |
static double |
static double |
40 |
94 |
convert_gregorian_to_julian(int year, int month, int day) |
convert_gregorian_to_julian(int year, int month, int day) |
41 |
95 |
{ |
{ |
|
... |
... |
convert_gregorian_to_julian(int year, int month, int day) |
46 |
100 |
double A = floor((double)year / 100); |
double A = floor((double)year / 100); |
47 |
101 |
double B = 2 - A + floor(A / 4); |
double B = 2 - A + floor(A / 4); |
48 |
102 |
double result = floor(365.25 * ((double)year + 4716)) + |
double result = floor(365.25 * ((double)year + 4716)) + |
49 |
|
floor(30.6001 * ((double)month + 1)) + |
|
50 |
|
(double)day + B - 1524.5; |
|
|
103 |
|
floor(30.6001 * ((double)month + 1)) + |
|
104 |
|
(double)day + B - 1524.5; |
51 |
105 |
return result; |
return result; |
52 |
106 |
} |
} |
53 |
107 |
|
|
|
... |
... |
get_equation_time(const unsigned long jdn, double *D) |
80 |
134 |
double d; /* Julian Day Number from 1 January 2000 */ |
double d; /* Julian Day Number from 1 January 2000 */ |
81 |
135 |
double g; /* Mean anomaly of the Sun */ |
double g; /* Mean anomaly of the Sun */ |
82 |
136 |
double q; /* Mean longitude of the Sun */ |
double q; /* Mean longitude of the Sun */ |
83 |
|
double L; /* Geocentric apparent ecliptic longitude of the Sun |
|
84 |
|
(adjusted for aberration) */ |
|
85 |
|
// double R; /* The approximated distance of the Sun from the Earth |
|
86 |
|
// in astronomical units (AU) */ |
|
|
137 |
|
double L; /* Geocentric apparent ecliptic longitude of the Sun */ |
87 |
138 |
double e; /* The mean obliquity of the ecliptic */ |
double e; /* The mean obliquity of the ecliptic */ |
88 |
139 |
double RA; /* The Sun's right ascension */ |
double RA; /* The Sun's right ascension */ |
89 |
|
// double D; /* The Sun's Declination */ |
|
90 |
140 |
double EqT; /* The Equation of Time */ |
double EqT; /* The Equation of Time */ |
91 |
|
// double SD; /* The angular semidiameter of the Sun in degrees */ |
|
92 |
141 |
|
|
93 |
142 |
// assert (jdn > 2451545); |
// assert (jdn > 2451545); |
94 |
143 |
|
|
|
... |
... |
get_equation_time(const unsigned long jdn, double *D) |
97 |
146 |
q = 280.459 + 0.98564736 * d; |
q = 280.459 + 0.98564736 * d; |
98 |
147 |
L = q + 1.915 * sin(convert_degrees_to_radians(g)) + \ |
L = q + 1.915 * sin(convert_degrees_to_radians(g)) + \ |
99 |
148 |
0.020 * sin(convert_degrees_to_radians(2.0*g)); |
0.020 * sin(convert_degrees_to_radians(2.0*g)); |
100 |
|
// R = 1.00014 - 0.01671 * cos(to_radians(g)) - |
|
101 |
|
// 0.00014 * cos(to_radians(2.0*g)); |
|
102 |
149 |
e = 23.439 - 0.00000036 * d; |
e = 23.439 - 0.00000036 * d; |
103 |
150 |
RA = convert_radians_to_degrees(atan2(cos(convert_degrees_to_radians(e)) * sin(convert_degrees_to_radians(L)), |
RA = convert_radians_to_degrees(atan2(cos(convert_degrees_to_radians(e)) * sin(convert_degrees_to_radians(L)), |
104 |
151 |
cos(convert_degrees_to_radians(L)))/15.0); |
cos(convert_degrees_to_radians(L)))/15.0); |
105 |
152 |
*D = convert_radians_to_degrees(asin(sin(convert_degrees_to_radians(e)) * sin(convert_degrees_to_radians(L)))); |
*D = convert_radians_to_degrees(asin(sin(convert_degrees_to_radians(e)) * sin(convert_degrees_to_radians(L)))); |
106 |
153 |
EqT = q/15.0 - RA; |
EqT = q/15.0 - RA; |
107 |
|
|
|
108 |
|
/* Resulting EqT Can be larger than 360. |
|
109 |
|
* Therefore, it needs normalization */ |
|
110 |
154 |
EqT = normalize(EqT, 360.0); |
EqT = normalize(EqT, 360.0); |
111 |
|
// SD = 0.2666 / R; |
|
112 |
155 |
return EqT; |
return EqT; |
113 |
|
// coord->D = D; |
|
114 |
|
// coord->EqT = EqT; |
|
115 |
|
// coord->R = R; |
|
116 |
|
// coord->SD = SD; |
|
117 |
156 |
} |
} |
118 |
157 |
|
|
119 |
158 |
static double |
static double |
|
... |
... |
get_sunrise(double dhuhr, double latitude, double altitude, double D) |
150 |
189 |
|
|
151 |
190 |
/* Prayers Function */ |
/* Prayers Function */ |
152 |
191 |
static double |
static double |
153 |
|
get_fajr(double duhr, double latitude, double D, short fajr_angle) |
|
|
192 |
|
get_fajr(double duhr, double latitude, double D, double fajr_angle) |
154 |
193 |
{ |
{ |
155 |
194 |
double fajr = duhr - T(fajr_angle, latitude, D); |
double fajr = duhr - T(fajr_angle, latitude, D); |
156 |
195 |
return fajr; |
return fajr; |
|
... |
... |
get_maghrib(double dhuhr, double latitude, double altitude, double D) |
190 |
229 |
} |
} |
191 |
230 |
|
|
192 |
231 |
static double |
static double |
193 |
|
get_isha(double duhr, double maghrib, double latitude, double altitude, |
|
194 |
|
double D, double isha_angle) |
|
|
232 |
|
get_isha(double duhr, double maghrib, double latitude, double D, |
|
233 |
|
double isha_angle) |
195 |
234 |
{ |
{ |
196 |
235 |
double one_min = 60.0/3600.0; |
double one_min = 60.0/3600.0; |
197 |
236 |
double isha; |
double isha; |
|
... |
... |
get_isha(double duhr, double maghrib, double latitude, double altitude, |
213 |
252 |
return isha; |
return isha; |
214 |
253 |
} |
} |
215 |
254 |
|
|
216 |
|
static double |
|
217 |
|
get_next_fajr(double fajr) |
|
218 |
|
{ |
|
219 |
|
return fajr; |
|
220 |
|
} |
|
|
255 |
|
// static double |
|
256 |
|
// get_next_fajr(double fajr) |
|
257 |
|
// { |
|
258 |
|
// return fajr; |
|
259 |
|
// } |
221 |
260 |
|
|
222 |
261 |
void |
void |
223 |
262 |
tests(void) |
tests(void) |
|
... |
... |
tests(void) |
228 |
267 |
int month = current_date.tm_mon + 1; |
int month = current_date.tm_mon + 1; |
229 |
268 |
int year = current_date.tm_year + 1900; |
int year = current_date.tm_year + 1900; |
230 |
269 |
printf("Today Date\t%.2i %.2i %.2i\n\n", day, month, year); |
printf("Today Date\t%.2i %.2i %.2i\n\n", day, month, year); |
|
270 |
|
|
|
271 |
|
/* Print Next Prayer left duration */ |
|
272 |
|
// printf("fajr\t\t%lf\nsunrise\t\t%lf\nduhr\t\t%lf\nasr\t\t%lf\nmaghrib\t\t%lf\nisha\t\t%lf\n", |
|
273 |
|
// fajr, |
|
274 |
|
// sunrise, |
|
275 |
|
// duhr, |
|
276 |
|
// asr, |
|
277 |
|
// maghrib, |
|
278 |
|
// isha); |
|
279 |
|
|
|
280 |
|
// printf("\nUnixTime\nfaj\t\t%ld\nsunrise\t\t%ld\nduhr\t\t%ld\nasr\t\t%ld\nmaghrib\t\t%ld\nisha\t\t%ld\n", |
|
281 |
|
// convert_today_double_to_timet(fajr), |
|
282 |
|
// convert_today_double_to_timet(sunrise), |
|
283 |
|
// convert_today_double_to_timet(duhr), |
|
284 |
|
// convert_today_double_to_timet(asr), |
|
285 |
|
// convert_today_double_to_timet(maghrib), |
|
286 |
|
// convert_today_double_to_timet(isha)); |
|
287 |
|
} |
|
288 |
|
|
|
289 |
|
static int |
|
290 |
|
file_exist(char* filename) |
|
291 |
|
{ |
|
292 |
|
/* try to open file to read */ |
|
293 |
|
FILE *file; |
|
294 |
|
file = fopen(filename, "r"); |
|
295 |
|
if(file != NULL){ |
|
296 |
|
(void)fclose(file); |
|
297 |
|
return 0; |
|
298 |
|
} |
|
299 |
|
return -1; |
|
300 |
|
} |
|
301 |
|
|
|
302 |
|
static int |
|
303 |
|
create_cache_file(char* cache_dir, char* full_path, time_t* prayer_array) |
|
304 |
|
{ |
|
305 |
|
/* Create cache dir if not exists*/ |
|
306 |
|
int dir_stat = mkdir(cache_dir, 0700); |
|
307 |
|
// if (dir_stat < 0){ |
|
308 |
|
// printf("Directory Status %i\n", dir_stat); |
|
309 |
|
// } |
|
310 |
|
|
|
311 |
|
/* Create cache file */ |
|
312 |
|
FILE* fpointer; |
|
313 |
|
fpointer = fopen(full_path, "w"); |
|
314 |
|
chmod(full_path, 00400); /* Change permission to read only*/ |
|
315 |
|
// (void)puts(full_path); |
|
316 |
|
|
|
317 |
|
if(fpointer == NULL){ |
|
318 |
|
printf("[Error] opening lp cache file.\n"); |
|
319 |
|
exit(EXIT_FAILURE); |
|
320 |
|
} |
|
321 |
|
|
|
322 |
|
fprintf(fpointer, "%ld\n%ld\n%ld\n%ld\n%ld", |
|
323 |
|
(long)prayer_array[0], |
|
324 |
|
(long)prayer_array[1], |
|
325 |
|
(long)prayer_array[2], |
|
326 |
|
(long)prayer_array[3], |
|
327 |
|
(long)prayer_array[4] |
|
328 |
|
); |
|
329 |
|
|
|
330 |
|
(void)fclose(fpointer); |
|
331 |
|
return 0; |
|
332 |
|
} |
|
333 |
|
|
|
334 |
|
static time_t* |
|
335 |
|
read_azan_cache_file(char* azan_cache_file) |
|
336 |
|
{ |
|
337 |
|
FILE* fp; |
|
338 |
|
char buffer[2048]; |
|
339 |
|
|
|
340 |
|
/* Read the cache file */ |
|
341 |
|
fp = fopen(azan_cache_file,"r"); |
|
342 |
|
if(fp == NULL){ |
|
343 |
|
printf("[Error] opening azan cache file."); |
|
344 |
|
exit(EXIT_FAILURE); |
|
345 |
|
} |
|
346 |
|
(void)fread(buffer, 2048, 1, fp); |
|
347 |
|
(void)fclose(fp); |
|
348 |
|
|
|
349 |
|
// other way to strncpy buffer with specific char n |
|
350 |
|
// printf("%s\n\n", buffer); |
|
351 |
|
static time_t pray_times_array[6]; /* the returned array */ |
|
352 |
|
char* tmp_pray[6]; /* string array hold temp values for checking */ |
|
353 |
|
|
|
354 |
|
// TODO |
|
355 |
|
// replace strstr: |
|
356 |
|
// read buffer to specific length |
|
357 |
|
|
|
358 |
|
/* |
|
359 |
|
* split each key value sepeated by <,> |
|
360 |
|
* the first strtok should take the string |
|
361 |
|
* if the value is not NULL: |
|
362 |
|
* 1-clean_json string, 2-convert to time_t 3-assign to returned array |
|
363 |
|
*/ |
|
364 |
|
char delim[] = "\n"; |
|
365 |
|
|
|
366 |
|
for(int i=0; i<5; i++){ |
|
367 |
|
if (i == 0) { |
|
368 |
|
tmp_pray[0] = strtok(buffer, delim); |
|
369 |
|
} else { |
|
370 |
|
tmp_pray[i] = strtok(NULL, delim); |
|
371 |
|
// pray_times_array[i] = (time_t)tmp_pray[i]; |
|
372 |
|
} |
|
373 |
|
if (tmp_pray[i] != NULL) { |
|
374 |
|
pray_times_array[i] = (time_t)atol(tmp_pray[i]); |
|
375 |
|
} |
|
376 |
|
} |
|
377 |
|
// for(int i=0; i<5; i++){printf("%ld\n", pray_times_array[i]);} |
|
378 |
|
return pray_times_array; |
|
379 |
|
} |
|
380 |
|
|
|
381 |
|
static int |
|
382 |
|
print_next_prayer(time_t current_time, char* azan_cache_file) |
|
383 |
|
{ |
|
384 |
|
time_t* azan_array; |
|
385 |
|
azan_array = read_azan_cache_file(azan_cache_file); |
|
386 |
|
|
|
387 |
|
if(azan_array == NULL){ |
|
388 |
|
printf("Error! reading array [ Line %d ]\n", __LINE__); |
|
389 |
|
exit(EXIT_FAILURE); |
|
390 |
|
} |
|
391 |
|
|
|
392 |
|
for (size_t i=0; i<5; i++) { |
|
393 |
|
// printf("%ld\n", (long)azan_array[i]); |
|
394 |
|
// printf("%s\n", convert_timet_to_str(azan_array[i])); |
|
395 |
|
|
|
396 |
|
if (azan_array[i] > current_time){ |
|
397 |
|
int left_seconds = difftime(azan_array[i], current_time); |
|
398 |
|
printf("%c %s\n", conv_prayer_int_to_char(i), convert_sec_int_to_min_hour(left_seconds)); |
|
399 |
|
|
|
400 |
|
break; /* Print first prayer only */ |
|
401 |
|
} |
|
402 |
|
|
|
403 |
|
} |
|
404 |
|
|
|
405 |
|
return 0; |
|
406 |
|
} |
|
407 |
|
|
|
408 |
|
static char |
|
409 |
|
conv_prayer_int_to_char(int pray_numb) |
|
410 |
|
{ |
|
411 |
|
switch (pray_numb) { |
|
412 |
|
case 0: return 'F'; |
|
413 |
|
case 1: return 'D'; |
|
414 |
|
case 2: return 'A'; |
|
415 |
|
case 3: return 'M'; |
|
416 |
|
case 4: return 'I'; |
|
417 |
|
case 5: return 'F'; |
|
418 |
|
} |
231 |
419 |
} |
} |
232 |
420 |
|
|
233 |
421 |
int |
int |
234 |
422 |
main(void) |
main(void) |
235 |
423 |
{ |
{ |
236 |
|
/* Current date time */ |
|
|
424 |
|
/* Current date time */ |
237 |
425 |
time_t t = time(NULL); |
time_t t = time(NULL); |
238 |
426 |
struct tm current_date = *localtime(&t); |
struct tm current_date = *localtime(&t); |
239 |
427 |
int day = current_date.tm_mday; |
int day = current_date.tm_mday; |
|
... |
... |
main(void) |
241 |
429 |
int year = current_date.tm_year + 1900; |
int year = current_date.tm_year + 1900; |
242 |
430 |
double julian_date = convert_gregorian_to_julian(year, month, day); |
double julian_date = convert_gregorian_to_julian(year, month, day); |
243 |
431 |
|
|
244 |
|
/* Equation of Time */ |
|
|
432 |
|
/* Equation of Time */ |
245 |
433 |
double D; |
double D; |
246 |
434 |
double equation_of_time = get_equation_time(julian_date, &D); |
double equation_of_time = get_equation_time(julian_date, &D); |
247 |
|
// printf("EqTmine = %lf\n", equation_of_time); |
|
248 |
435 |
|
|
249 |
|
/* Today's Prayers time */ |
|
|
436 |
|
/* Today's Prayers time */ |
|
437 |
|
// FIXME 3 minutes less (duhr = 15 should be 18) |
250 |
438 |
double duhr = get_duhr(time_zone, longitude, equation_of_time); |
double duhr = get_duhr(time_zone, longitude, equation_of_time); |
251 |
439 |
double sunrise = get_sunrise(duhr, latitude, altitude, D); |
double sunrise = get_sunrise(duhr, latitude, altitude, D); |
|
440 |
|
// TODO fajr sunrise |
|
441 |
|
// fajr = get_fajr(true_noon, sunset_prev, sunrise, loc, &coord); |
252 |
442 |
double fajr = get_fajr(duhr, latitude, D, fajr_angle); |
double fajr = get_fajr(duhr, latitude, D, fajr_angle); |
253 |
443 |
double maghrib = get_maghrib(duhr, latitude, altitude, D); |
double maghrib = get_maghrib(duhr, latitude, altitude, D); |
254 |
|
double isha = get_isha(duhr, maghrib, latitude, altitude, D, isha_angle); |
|
|
444 |
|
//TODO isha next sunrise |
|
445 |
|
//isha = get_isha(true_noon, sunset, sunrise_next, loc, &coord); |
|
446 |
|
double isha = get_isha(duhr, maghrib, latitude, D, isha_angle); |
255 |
447 |
double asr = get_asr(duhr, latitude, D); |
double asr = get_asr(duhr, latitude, D); |
256 |
448 |
// time_t next_fajr = get_next_fajr(duhr); |
// time_t next_fajr = get_next_fajr(duhr); |
257 |
449 |
|
|
258 |
|
/* Test */ |
|
259 |
|
tests(); |
|
|
450 |
|
/* Create Cache File */ |
|
451 |
|
size_t max_file_name = 128; |
|
452 |
|
static char cache_dir[128]; |
|
453 |
|
static char azan_cache_file[128]; |
|
454 |
|
|
|
455 |
|
char* user_home = getenv("HOME"); |
|
456 |
|
(void)snprintf(cache_dir, max_file_name, "%s/.cache/azan", user_home); |
|
457 |
|
(void)snprintf(azan_cache_file, max_file_name, "azan_%.2i-%.2i-%i.txt", |
|
458 |
|
day, month, year); |
|
459 |
|
|
|
460 |
|
char full_path[256]; |
|
461 |
|
strcpy(full_path, cache_dir); |
|
462 |
|
strcat(full_path, "/"); |
|
463 |
|
strcat(full_path, azan_cache_file); |
|
464 |
|
|
|
465 |
|
if (file_exist(full_path) < 0){ |
|
466 |
|
/* Convert prayer times to unix timestamp */ |
|
467 |
|
static time_t prayer_array[6]; |
|
468 |
|
prayer_array[0] = convert_today_double_to_timet(fajr); |
|
469 |
|
prayer_array[1] = convert_today_double_to_timet(duhr); |
|
470 |
|
prayer_array[2] = convert_today_double_to_timet(asr); |
|
471 |
|
prayer_array[3] = convert_today_double_to_timet(maghrib); |
|
472 |
|
prayer_array[4] = convert_today_double_to_timet(isha); |
|
473 |
|
|
|
474 |
|
/* Write timestamp to cache file */ |
|
475 |
|
if (create_cache_file(cache_dir, full_path, prayer_array) < 0) { |
|
476 |
|
printf("Error Creating Cache File\n"); |
|
477 |
|
return -1; |
|
478 |
|
} |
|
479 |
|
|
|
480 |
|
/* Read cache file */ |
|
481 |
|
} else { |
|
482 |
|
if (print_next_prayer(t, full_path) < 0){ |
|
483 |
|
printf("Error Reading Cache File\n"); |
|
484 |
|
return -1; |
|
485 |
|
} |
|
486 |
|
} |
260 |
487 |
|
|
261 |
|
/* Print Next Prayer left duration */ |
|
262 |
|
printf("fajr\t\t%lf\nsunrise\t\t%lf\nduhr\t\t%lf\nasr\t\t%lf\nmaghrib\t\t%lf\nisha\t\t%lf\n", |
|
263 |
|
fajr, |
|
264 |
|
sunrise, |
|
265 |
|
duhr, |
|
266 |
|
asr, |
|
267 |
|
maghrib, |
|
268 |
|
isha); |
|
269 |
|
|
|
270 |
|
printf("\nUnixTime\nfaj\t\t%ld\nsunrise\t\t%ld\nduhr\t\t%ld\nasr\t\t%ld\nmaghrib\t\t%ld\nisha\t\t%ld\n", |
|
271 |
|
convert_today_double_to_timet(fajr), |
|
272 |
|
convert_today_double_to_timet(sunrise), |
|
273 |
|
convert_today_double_to_timet(duhr), |
|
274 |
|
convert_today_double_to_timet(asr), |
|
275 |
|
convert_today_double_to_timet(maghrib), |
|
276 |
|
convert_today_double_to_timet(isha)); |
|
|
488 |
|
/* Test */ |
|
489 |
|
// tests(); |
277 |
490 |
|
|
278 |
491 |
return 0; |
return 0; |
279 |
492 |
} |
} |
File azan.h changed (mode: 100644) (index 2725031..078368d) |
... |
... |
Description : |
22 |
22 |
|
|
23 |
23 |
/* function declarations */ |
/* function declarations */ |
24 |
24 |
static time_t convert_today_double_to_timet(double event_time); |
static time_t convert_today_double_to_timet(double event_time); |
25 |
|
static time_t convert_today_double_to_timet(double event_time); |
|
|
25 |
|
static char* convert_timet_to_str(time_t input_time); |
|
26 |
|
static char* convert_sec_int_to_min_hour(int input_seconds); |
26 |
27 |
static double convert_gregorian_to_julian(int year, int month, int day); |
static double convert_gregorian_to_julian(int year, int month, int day); |
27 |
28 |
static double convert_degrees_to_radians(const double x); |
static double convert_degrees_to_radians(const double x); |
28 |
29 |
static double convert_radians_to_degrees(const double x); |
static double convert_radians_to_degrees(const double x); |
|
... |
... |
static double get_equation_time(const unsigned long jdn, double *D); |
31 |
32 |
static double T(const double alpha,const double latitude,const double D); |
static double T(const double alpha,const double latitude,const double D); |
32 |
33 |
static double A(const double t, const double latitude, const double D); |
static double A(const double t, const double latitude, const double D); |
33 |
34 |
static double get_sunrise(double dhuhr, double latitude, double altitude, double D); |
static double get_sunrise(double dhuhr, double latitude, double altitude, double D); |
34 |
|
static double get_fajr(double duhr, double latitude, double D, short fajr_angle); |
|
|
35 |
|
static double get_fajr(double duhr, double latitude, double D, double fajr_angle); |
35 |
36 |
static double get_duhr(double timezone, double longitude, double EqT); |
static double get_duhr(double timezone, double longitude, double EqT); |
36 |
37 |
static double get_asr(double duhr, double latitude, double D); |
static double get_asr(double duhr, double latitude, double D); |
37 |
38 |
static double get_maghrib(double dhuhr, double latitude, double altitude, double D); |
static double get_maghrib(double dhuhr, double latitude, double altitude, double D); |
38 |
|
static double get_isha(double duhr, double maghrib, double latitude, double altitude, double D, double isha_angle); |
|
39 |
|
static double get_next_fajr(double fajr); |
|
|
39 |
|
static double get_isha(double duhr, double maghrib, double latitude, double D, double isha_angle); |
|
40 |
|
static int file_exist(char* filename); |
|
41 |
|
static int create_cache_file(char* cache_dir, char* full_path, time_t* prayer_array); |
|
42 |
|
static time_t* read_azan_cache_file(char* azan_cache_file); |
|
43 |
|
static int print_next_prayer(time_t current_time, char* azan_cache_file); |
|
44 |
|
static char conv_prayer_int_to_char(int pray_numb); |
|
45 |
|
// static double get_next_fajr(double fajr); |
40 |
46 |
void tests(void); |
void tests(void); |
41 |
47 |
|
|
42 |
48 |
// static Prayer todays_prayers[6] = { |
// static Prayer todays_prayers[6] = { |