[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-commit] [2323] Edited daylight_seconds() for readability
From: |
Mike Rice |
Subject: |
[avr-libc-commit] [2323] Edited daylight_seconds() for readability |
Date: |
Tue, 02 Apr 2013 21:08:04 +0000 |
Revision: 2323
http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2323
Author: swfltek
Date: 2013-04-02 21:08:04 +0000 (Tue, 02 Apr 2013)
Log Message:
-----------
Edited daylight_seconds() for readability
Modified Paths:
--------------
trunk/avr-libc/libc/time/daylight_seconds.c
Modified: trunk/avr-libc/libc/time/daylight_seconds.c
===================================================================
--- trunk/avr-libc/libc/time/daylight_seconds.c 2013-04-02 20:59:28 UTC (rev
2322)
+++ trunk/avr-libc/libc/time/daylight_seconds.c 2013-04-02 21:08:04 UTC (rev
2323)
@@ -29,8 +29,8 @@
/* $Id$ */
/*
- Determine the amount of time the sun is above the horizon. At high
latitudes, this can be zero,
- or >= ONE_DAY.
+ Determine the amount of time the sun is above the horizon. At high
latitudes, this can be zero,
+ or >= ONE_DAY.
*/
#include <time.h>
@@ -41,27 +41,28 @@
long
daylight_seconds(time_t * timer)
{
- double l, d;
- long n;
+ double l, d;
+ long n;
- /* convert latitude to radians */
- l = __latitude / 206264.806;
+ /* convert latitude to radians */
+ l = __latitude / 206264.806;
- d = -solar_declination(timer);
+ d = -solar_declination(timer);
- d = tan(l) * tan(d);
+ d = tan(l) * tan(d);
- if (d > 1.0)
- d = 1.0;
+ /* d may exceed a magnitude of 1.0 at high latitudes */
+ if (d > 1.0)
+ d = 1.0;
- if (d < -1.0)
- d = -1.0;
+ if (d < -1.0)
+ d = -1.0;
- d = acos(d);
+ d = acos(d);
- d /= 3.112505;
+ d /= 3.112505;
- n = ONE_DAY * d;
+ n = ONE_DAY * d;
- return n;
+ return n;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-commit] [2323] Edited daylight_seconds() for readability,
Mike Rice <=