wmbiff: fixed possible null-pointer dereference.
[dockapps.git] / wmcalendar / Src / calendarfunc.h
blobd50ddf83dac494ffc4472d0a0ebf75a29e6b9178
1 /* persian calendar functions original code is by Kees Couprie
2 http://www.geocities.com/couprie/calmath/ */
4 /* islamic conversion and moonphase calculation is taken from
6 * hdate
8 * Copyright (c) 1992 by Waleed A. Muhanna
10 * Permission for nonprofit use and redistribution of this software and
11 * its documentation is hereby granted without fee, provided that the
12 * above copyright notice appear in all copies and that both that copyright
13 * notice and this permission notice appear in supporting documentation.
15 * No representation is made about the suitability of this software for any
16 * purpose. It is provided "as is" without express or implied warranty.
18 * Send any comments/suggestions/fixes/additions to:
19 * wmuhanna@magnus.acs.ohio-state.edu
23 #include <unistd.h>
24 #include <stdlib.h>
25 #include <libical/ical.h>
26 #include <math.h>
27 #define TIMZ 3.0
28 #define MINAGE 13.5
29 #define SUNSET 19.5 /*approximate */
30 #define TIMDIF (SUNSET-MINAGE)
31 #define NMONTHS (1405*12+1)
32 #define RPD (0.01745329251994329577) /* radians per degree (pi/180) */
33 /*general*/
34 int days_in_month(int month, int year, int calendar);
35 int day_of_week(struct icaltimetype dt);
37 /* related to gregorian calendar*/
38 struct icaltimetype get_civil(struct icaltimetype dt, int calendar);
39 long civil_jdn(struct icaltimetype dt);
40 struct icaltimetype jdn_civil(long jdn);
41 int isGregorianLeap(int year);
42 int days_in_gregorian_month(int month, int year);
44 /*related to persian calendar*/
45 long persian_jdn(struct icaltimetype dt);
46 struct icaltimetype jdn_persian(long jdn);
47 struct icaltimetype civil_persian(struct icaltimetype dt);
48 struct icaltimetype persian_civil(struct icaltimetype dt);
49 int isPersianLeap(int year);
50 int days_in_persian_month(int month, int year);
52 /*related to islamic calendar*/
53 long islamic_jdn(struct icaltimetype dt);
54 struct icaltimetype jdn_islamic(long jdn);
55 struct icaltimetype civil_islamic(struct icaltimetype dt);
56 struct icaltimetype islamic_civil(struct icaltimetype dt);
57 int days_in_islamic_month(int month, int year);
60 /*moonphase*/
61 int moon(struct icaltimetype dt);
64 /*day comparing functions*/
65 int daysComp(struct icaltimetype d1, struct icaltimetype d2);
66 int daysEqual(struct icaltimetype d1, struct icaltimetype d2);
67 int daysLater(struct icaltimetype d1, struct icaltimetype d2);
68 int daysEarlier(struct icaltimetype d1, struct icaltimetype d2);
69 int daysLaterEqual(struct icaltimetype d1, struct icaltimetype d2);
70 int daysEarlierEqual(struct icaltimetype d1, struct icaltimetype d2);
72 int Ceil(float number);
74 int datemoon[200][2]; /* hashtable for moonphase.[jdn%32][0] stores moonphase of day jdn,
75 [jdn%32][1] stores jdn. */