[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-libc-commit] [2343] Pulled the calculation of solar noon from sun_r
From: |
Mike Rice |
Subject: |
[avr-libc-commit] [2343] Pulled the calculation of solar noon from sun_rise.c and sun_set.c, creating new function solar_noon(). |
Date: |
Tue, 09 Apr 2013 20:07:01 +0000 |
Revision: 2343
http://svn.sv.gnu.org/viewvc/?view=rev&root=avr-libc&revision=2343
Author: swfltek
Date: 2013-04-09 20:07:01 +0000 (Tue, 09 Apr 2013)
Log Message:
-----------
Pulled the calculation of solar noon from sun_rise.c and sun_set.c, creating
new function solar_noon().
Modified Paths:
--------------
trunk/avr-libc/include/time.h
trunk/avr-libc/libc/time/sun_rise.c
trunk/avr-libc/libc/time/sun_set.c
Added Paths:
-----------
trunk/avr-libc/libc/time/solar_noon.c
Modified: trunk/avr-libc/include/time.h
===================================================================
--- trunk/avr-libc/include/time.h 2013-04-09 20:04:59 UTC (rev 2342)
+++ trunk/avr-libc/include/time.h 2013-04-09 20:07:01 UTC (rev 2343)
@@ -375,6 +375,11 @@
int32_t daylight_seconds(time_t * timer);
/**
+ Computes the time of solar noon, at the location of the observer.
+ */
+ time_t solar_noon(time_t * timer);
+
+ /**
Return the time of sunrise, at the location of the observer. See the
note about daylight_seconds().
*/
time_t sun_rise(time_t * timer);
Added: trunk/avr-libc/libc/time/solar_noon.c
===================================================================
--- trunk/avr-libc/libc/time/solar_noon.c (rev 0)
+++ trunk/avr-libc/libc/time/solar_noon.c 2013-04-09 20:07:01 UTC (rev
2343)
@@ -0,0 +1,57 @@
+/*
+ * (c)2012 Michael Duane Rice All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions
+ * and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution. Neither the name of the copyright holders
+ * nor the names of contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* $Id$ */
+
+/*
+ Return the time of solar noon at the observers position
+*/
+
+#include <time.h>
+
+extern long __longitude;
+
+time_t
+solar_noon(time_t * timer)
+{
+ time_t t;
+ long n;
+
+ /* determine time of solar noon at the prime meridian */
+ t = *timer % ONE_DAY;
+ t = *timer - t;
+ t += 43200L;
+ t -= equation_of_time(timer);
+
+ /* rotate to observers longitude */
+ n = __longitude / 15L;
+ t -= n;
+
+ return t;
+
+}
Property changes on: trunk/avr-libc/libc/time/solar_noon.c
___________________________________________________________________
Added: svn:keywords
+ ID
Modified: trunk/avr-libc/libc/time/sun_rise.c
===================================================================
--- trunk/avr-libc/libc/time/sun_rise.c 2013-04-09 20:04:59 UTC (rev 2342)
+++ trunk/avr-libc/libc/time/sun_rise.c 2013-04-09 20:07:01 UTC (rev 2343)
@@ -33,7 +33,6 @@
*/
#include <time.h>
-extern long __longitude;
time_t
sun_rise(time_t * timer)
@@ -41,19 +40,10 @@
long n;
time_t t;
- /* determine time of solar noon at the prime meridian */
- t = *timer % ONE_DAY;
- t = *timer - t;
- t += 43200L;
- t -= equation_of_time(timer);
-
- /* sunrise is 1/2 day earlier */
+ /* sunrise is 1/2 'day' before solar noon */
+ t = solar_noon(timer);
n = daylight_seconds(timer) / 2L;
t -= n;
- /* rotate to observers longitude */
- n = __longitude / 15L;
- t -= n;
-
return t;
}
Modified: trunk/avr-libc/libc/time/sun_set.c
===================================================================
--- trunk/avr-libc/libc/time/sun_set.c 2013-04-09 20:04:59 UTC (rev 2342)
+++ trunk/avr-libc/libc/time/sun_set.c 2013-04-09 20:07:01 UTC (rev 2343)
@@ -33,7 +33,6 @@
*/
#include <time.h>
-extern long __longitude;
time_t
sun_set(time_t * timer)
@@ -41,19 +40,11 @@
long n;
time_t t;
- /* determine time of solar noon at the prime meridian */
- t = *timer % ONE_DAY;
- t = *timer - t;
- t += 43200L;
- t -= equation_of_time(timer);
-
- /* sunset is 1/2 day earlier */
+ /* sunset is 1/2 'day' after solar noon */
+ t = solar_noon(timer);
n = daylight_seconds(timer) / 2L;
t += n;
- /* rotate to observers longitude */
- n = __longitude / 15L;
- t -= n;
-
return t;
+
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [avr-libc-commit] [2343] Pulled the calculation of solar noon from sun_rise.c and sun_set.c, creating new function solar_noon().,
Mike Rice <=