[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-commit] [2331] Edited sun_rise() and sun_set() for clarity
From: |
Mike Rice |
Subject: |
[avr-libc-commit] [2331] Edited sun_rise() and sun_set() for clarity |
Date: |
Tue, 02 Apr 2013 21:48:00 +0000 |
Revision: 2331
http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2331
Author: swfltek
Date: 2013-04-02 21:48:00 +0000 (Tue, 02 Apr 2013)
Log Message:
-----------
Edited sun_rise() and sun_set() for clarity
Modified Paths:
--------------
trunk/avr-libc/libc/time/sun_rise.c
trunk/avr-libc/libc/time/sun_set.c
Modified: trunk/avr-libc/libc/time/sun_rise.c
===================================================================
--- trunk/avr-libc/libc/time/sun_rise.c 2013-04-02 21:46:13 UTC (rev 2330)
+++ trunk/avr-libc/libc/time/sun_rise.c 2013-04-02 21:48:00 UTC (rev 2331)
@@ -29,7 +29,7 @@
/* $Id$ */
/*
- Return the approximate time of sun rise.
+ Return the approximate time of sun rise.
*/
#include <time.h>
@@ -38,19 +38,22 @@
time_t
sun_rise(time_t * timer)
{
- long n;
- time_t t;
+ long n;
+ time_t t;
- t = *timer % 86400UL;
- t = *timer - t;
- t += 43200L;
- t -= equation_of_time(timer);
+ /* determine time of solar noon at the prime meridian */
+ t = *timer % ONE_DAY;
+ t = *timer - t;
+ t += 43200L;
+ t -= equation_of_time(timer);
- n = daylight_seconds(timer) / 2L;
- t -= n;
+ /* sunrise is 1/2 day earlier */
+ n = daylight_seconds(timer) / 2L;
+ t -= n;
- n = __longitude / 15L;
- t -= n;
+ /* rotate to observers longitude */
+ n = __longitude / 15L;
+ t -= n;
- return t;
+ return t;
}
Modified: trunk/avr-libc/libc/time/sun_set.c
===================================================================
--- trunk/avr-libc/libc/time/sun_set.c 2013-04-02 21:46:13 UTC (rev 2330)
+++ trunk/avr-libc/libc/time/sun_set.c 2013-04-02 21:48:00 UTC (rev 2331)
@@ -29,7 +29,7 @@
/* $Id$ */
/*
- Return the approximate time of sun set.
+ Return the approximate time of sun set.
*/
#include <time.h>
@@ -38,19 +38,22 @@
time_t
sun_set(time_t * timer)
{
- long n;
- time_t t;
+ long n;
+ time_t t;
- t = *timer % 86400UL;
- t = *timer - t;
- t += 43200L;
- t -= equation_of_time(timer);
+ /* determine time of solar noon at the prime meridian */
+ t = *timer % ONE_DAY;
+ t = *timer - t;
+ t += 43200L;
+ t -= equation_of_time(timer);
- n = daylight_seconds(timer) / 2L;
- t += n;
+ /* sunset is 1/2 day earlier */
+ n = daylight_seconds(timer) / 2L;
+ t += n;
- n = __longitude / 15L;
- t -= n;
+ /* rotate to observers longitude */
+ n = __longitude / 15L;
+ t -= n;
- return t;
+ return t;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-commit] [2331] Edited sun_rise() and sun_set() for clarity,
Mike Rice <=