php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
astro.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2015-2019 Derick Rethans
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25/* This macro computes the length of the day, from sunrise to sunset. */
26/* Sunrise/set is considered to occur when the Sun's upper limb is */
27/* 35 arc minutes below the horizon (this accounts for the refraction */
28/* of the Earth's atmosphere). */
29#define day_length(year,month,day,lon,lat) \
30 __daylen__( year, month, day, lon, lat, -35.0/60.0, 1 )
31
32/* This macro computes the length of the day, including civil twilight. */
33/* Civil twilight starts/ends when the Sun's center is 6 degrees below */
34/* the horizon. */
35#define day_civil_twilight_length(year,month,day,lon,lat) \
36 __daylen__( year, month, day, lon, lat, -6.0, 0 )
37
38/* This macro computes the length of the day, incl. nautical twilight. */
39/* Nautical twilight starts/ends when the Sun's center is 12 degrees */
40/* below the horizon. */
41#define day_nautical_twilight_length(year,month,day,lon,lat) \
42 __daylen__( year, month, day, lon, lat, -12.0, 0 )
43
44/* This macro computes the length of the day, incl. astronomical twilight. */
45/* Astronomical twilight starts/ends when the Sun's center is 18 degrees */
46/* below the horizon. */
47#define day_astronomical_twilight_length(year,month,day,lon,lat) \
48 __daylen__( year, month, day, lon, lat, -18.0, 0 )
49
50
51/* This macro computes times for sunrise/sunset. */
52/* Sunrise/set is considered to occur when the Sun's upper limb is */
53/* 35 arc minutes below the horizon (this accounts for the refraction */
54/* of the Earth's atmosphere). */
55#define timelib_astro_sun_rise_set(ts,lon,lat,hrise,hset,rise,set) \
56 timelib_astro_rise_set_altitude( ts, lon, lat, -35.0/60.0, 1, hrise, hset, rise, set )
57
58/* This macro computes the start and end times of civil twilight. */
59/* Civil twilight starts/ends when the Sun's center is 6 degrees below */
60/* the horizon. */
61#define civil_twilight(ts,lon,lat,start,end) \
62 timelib_astro_rise_set_altitude( ts, lon, lat, -6.0, 0, start, end )
63
64/* This macro computes the start and end times of nautical twilight. */
65/* Nautical twilight starts/ends when the Sun's center is 12 degrees */
66/* below the horizon. */
67#define nautical_twilight(ts,lon,lat,start,end) \
68 timelib_astro_rise_set_altitude( ts, lon, lat, -12.0, 0, start, end )
69
70/* This macro computes the start and end times of astronomical twilight. */
71/* Astronomical twilight starts/ends when the Sun's center is 18 degrees */
72/* below the horizon. */
73#define astronomical_twilight(ts,lon,lat,start,end) \
74 timelib_astro_rise_set_altitude( ts, lon, lat, -18.0, 0, start, end )