[gnome-clocks] world: don't compute twilights were we can't
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] world: don't compute twilights were we can't
- Date: Mon, 13 Apr 2020 22:43:16 +0000 (UTC)
commit 6bb7dc7c2eb66a9fd80905eaef3fdee15b99588d
Author: Manuel Genovés <manuel genoves gmail com>
Date: Mon Apr 13 03:48:23 2020 +0200
world: don't compute twilights were we can't
More or less fixes #91
This improves the handling of zones were we can't calculate twilight times,
adding the corrections used for determining what type of twilight
(civil/nautical/astronomical) and the corrections for the atmosphere's
refraction to the calculation of the "out-of-bonds" region.
We still should do some handling of these "out-of-bound" regions, since
actually we just return sunrise: 00:00:00 / sunset : 12:59:59 without
explicitly telling that those values are placeholder ones
Signed-off-by: Manuel Genovés <manuel genoves gmail com>
src/twilight.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/src/twilight.c b/src/twilight.c
index a706a23..dced3d4 100644
--- a/src/twilight.c
+++ b/src/twilight.c
@@ -124,9 +124,10 @@ calculate_sunrise_sunset (double lat,
// IMPORTANT: for polar circles we can't compute anything for certain dates
- if ((((is_in_north_summer (month) && (lat <= (d - 90))) || (lat >= (90 - d)))) ||
- (((is_in_north_winter (month) && (lat <= (-d - 90))) || (lat >= (90 + d))))) {
-
+ if ((((is_in_north_summer (month) && (lat <= (d + 0.83 + correction - 90))) ||
+ (lat >= (90 - d - 0.83 - correction)))) ||
+ (((is_in_north_winter (month) && (lat <= (-90 - d - 0.83 - correction))) ||
+ (lat >= (90 + d + 0.83 + correction))))) {
sunrise_hour = 0;
sunrise_minute = 0;
sunset_hour = 23;
@@ -141,7 +142,7 @@ calculate_sunrise_sunset (double lat,
// hour angle
double w = DEGREES (acos ((sin (RADIANS (-correction)) + sin (RADIANS (-0.83)) -
sin (RADIANS (lat)) * sin (RADIANS (d)))
- / (cos (RADIANS (lat))) * cos (RADIANS (d))));
+ / ((cos (RADIANS (lat))) * cos (RADIANS (d)))));
// julian sunrise
double J_sunrise = (J_transit - w / 360 - 0.5);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]