From 94d2d00f48cd9d62cf4a82dbc69b2c3eb83bcc23 Mon Sep 17 00:00:00 2001
From: rudolfkoenig <>
Date: Sun, 5 Oct 2014 07:21:36 +0000
Subject: [PATCH] 99_SUNRISE_EL.pm: sunrise_abs_dat/sub sunset_abs_dat from
Dietmar63 (Forum #27471)
git-svn-id: https://svn.fhem.de/fhem/trunk@6682 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/FHEM/99_SUNRISE_EL.pm | 47 ++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 12 deletions(-)
diff --git a/fhem/FHEM/99_SUNRISE_EL.pm b/fhem/FHEM/99_SUNRISE_EL.pm
index 906826da7..144b357b0 100755
--- a/fhem/FHEM/99_SUNRISE_EL.pm
+++ b/fhem/FHEM/99_SUNRISE_EL.pm
@@ -48,12 +48,13 @@ sub
sr($$$$$$)
{
my ($rise, $seconds, $isrel, $daycheck, $min, $max) = @_;
- sr_alt($rise, $isrel, $daycheck, $defaultaltit, $seconds, $min, $max);
+ sr_alt(time(), $rise, $isrel, $daycheck, $defaultaltit, $seconds, $min, $max);
}
sub
-sr_alt($$$$$$$)
+sr_alt($$$$$$$$)
{
+ my $nt=shift;
my $rise=shift;
my $isrel=shift;
my $daycheck=shift;
@@ -81,7 +82,7 @@ sr_alt($$$$$$$)
Log3 undef, 5, "Compute sunrise/sunset for latitude $lat , longitude $long";
- my $nt = time;
+ #my $nt = time;
my @lt = localtime($nt);
my $gmtoff = _calctz($nt,@lt); # in hour
@@ -358,16 +359,19 @@ h2hms_fmt($)
return sprintf("%02d:%02d:%02d", $h, $m, $s);
}
-
-sub sunrise_rel(@) { return sr_alt(1, 1, 0, shift, shift, shift, shift) }
-sub sunset_rel(@) { return sr_alt(0, 1, 0, shift, shift, shift, shift) }
-sub sunrise_abs(@) { return sr_alt(1, 0, 0, shift, shift, shift, shift) }
-sub sunset_abs(@) { return sr_alt(0, 0, 0, shift, shift, shift, shift) }
-sub sunrise(@) { return sr_alt(1, 2, 0, shift, shift, shift, shift) }
-sub sunset(@) { return sr_alt(0, 2, 0, shift, shift, shift, shift) }
-sub isday(@) { return sr_alt(1, 0, 1, shift, 0, undef, undef) }
sub sunrise_coord($$$) { ($long, $lat, $tz) = @_; return undef; }
+sub sunrise_rel (@) { return sr_alt(time(), 1, 1, 0, shift, shift, shift, shift) }
+sub sunset_rel (@) { return sr_alt(time(), 0, 1, 0, shift, shift, shift, shift) }
+sub sunrise_abs (@) { return sr_alt(time(), 1, 0, 0, shift, shift, shift, shift) }
+sub sunset_abs (@) { return sr_alt(time(), 0, 0, 0, shift, shift, shift, shift) }
+sub sunrise (@) { return sr_alt(time(), 1, 2, 0, shift, shift, shift, shift) }
+sub sunset (@) { return sr_alt(time(), 0, 2, 0, shift, shift, shift, shift) }
+sub isday (@) { return sr_alt(time(), 1, 0, 1, shift, 0, undef, undef) }
+
+sub sunrise_abs_dat(@) { return sr_alt(shift, 1, 0, 0, shift, shift, shift, shift) }
+sub sunset_abs_dat (@) { return sr_alt(shift, 0, 0, 0, shift, shift, shift, shift) }
+
1;
=pod
@@ -401,6 +405,9 @@ isday
sunrise/sunset.
sunrise_abs()/sunset_abs() return the absolute time of the corresponding
event today (no 24 hours added).
+ sunrise_abs_dat()/sunset_abs_dat() return the absolute time of the corresponding
+ event to a given date(no 24 hours added).
+
All functions take up to three arguments:
# When sun is 6 degrees below horizon - same as sunrise(); @@ -433,6 +440,22 @@ isday
+ # to calculate the sunrise of today + 7 days + my $date = time() + 7*86400; + sunrise_abs_dat($date); + + # to calculate the sunrise of today + 7 days 6 degrees below horizon + my $date = time() + 7*86400; + sunrise_abs_dat($date, "CIVIL"); + ++ Define