xref: /PHP-5.5/ext/date/lib/astro.h (revision 7b581f6d)
1 /* This macro computes the length of the day, from sunrise to sunset. */
2 /* Sunrise/set is considered to occur when the Sun's upper limb is    */
3 /* 35 arc minutes below the horizon (this accounts for the refraction */
4 /* of the Earth's atmosphere).                                        */
5 #define day_length(year,month,day,lon,lat)  \
6         __daylen__( year, month, day, lon, lat, -35.0/60.0, 1 )
7 
8 /* This macro computes the length of the day, including civil twilight. */
9 /* Civil twilight starts/ends when the Sun's center is 6 degrees below  */
10 /* the horizon.                                                         */
11 #define day_civil_twilight_length(year,month,day,lon,lat)  \
12         __daylen__( year, month, day, lon, lat, -6.0, 0 )
13 
14 /* This macro computes the length of the day, incl. nautical twilight.  */
15 /* Nautical twilight starts/ends when the Sun's center is 12 degrees    */
16 /* below the horizon.                                                   */
17 #define day_nautical_twilight_length(year,month,day,lon,lat)  \
18         __daylen__( year, month, day, lon, lat, -12.0, 0 )
19 
20 /* This macro computes the length of the day, incl. astronomical twilight. */
21 /* Astronomical twilight starts/ends when the Sun's center is 18 degrees   */
22 /* below the horizon.                                                      */
23 #define day_astronomical_twilight_length(year,month,day,lon,lat)  \
24         __daylen__( year, month, day, lon, lat, -18.0, 0 )
25 
26 
27 /* This macro computes times for sunrise/sunset.                      */
28 /* Sunrise/set is considered to occur when the Sun's upper limb is    */
29 /* 35 arc minutes below the horizon (this accounts for the refraction */
30 /* of the Earth's atmosphere).                                        */
31 #define timelib_astro_sun_rise_set(ts,lon,lat,hrise,hset,rise,set)  \
32         timelib_astro_rise_set_altitude( ts, lon, lat, -35.0/60.0, 1, hrise, hset, rise, set )
33 
34 /* This macro computes the start and end times of civil twilight.       */
35 /* Civil twilight starts/ends when the Sun's center is 6 degrees below  */
36 /* the horizon.                                                         */
37 #define civil_twilight(ts,lon,lat,start,end)  \
38         timelib_astro_rise_set_altitude( ts, lon, lat, -6.0, 0, start, end )
39 
40 /* This macro computes the start and end times of nautical twilight.    */
41 /* Nautical twilight starts/ends when the Sun's center is 12 degrees    */
42 /* below the horizon.                                                   */
43 #define nautical_twilight(ts,lon,lat,start,end)  \
44         timelib_astro_rise_set_altitude( ts, lon, lat, -12.0, 0, start, end )
45 
46 /* This macro computes the start and end times of astronomical twilight.   */
47 /* Astronomical twilight starts/ends when the Sun's center is 18 degrees   */
48 /* below the horizon.                                                      */
49 #define astronomical_twilight(ts,lon,lat,start,end)  \
50         timelib_astro_rise_set_altitude( ts, lon, lat, -18.0, 0, start, end )
51 
52