From 26d63b8cbbd5a80c578c49c08c1e3394c4fdbcc8 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sat, 31 Oct 2020 16:17:33 +0000 Subject: [PATCH] 76_SMAPortal: contrib 3.6.1 git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@23062 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- contrib/DS_Starter/76_SMAPortal.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/contrib/DS_Starter/76_SMAPortal.pm b/contrib/DS_Starter/76_SMAPortal.pm index a1a041210..a7fd3f84d 100644 --- a/contrib/DS_Starter/76_SMAPortal.pm +++ b/contrib/DS_Starter/76_SMAPortal.pm @@ -137,7 +137,7 @@ BEGIN { # Versions History intern my %vNotesIntern = ( - "3.6.1" => "31.10.2020 ", + "3.6.1" => "31.10.2020 adjust anchortime in getBalanceMonthData ", "3.6.0" => "11.10.2020 new relative time arguments for attr balanceDay, balanceMonth, balanceYear, new attribute useRelativeNames ", "3.5.0" => "10.10.2020 _getLiveData: get data from Dashboard instead of homemanager site depending of attr noHomeManager, ". "extract OperationHealth key, new attr cookieDelete ", @@ -1660,7 +1660,7 @@ sub _getBalanceMonthData { ## no critic "not used" $addon = createDateAddon ($params); } - my $dim = $m+1-2 ? 30+(($m+1)*3%7<4) : 28+!(($y+1900)%4||($y+1900)%400*!(($y+1900)%100)); # errechnet wieviel Tage der Monat hat + my $dim = daysInMonth ($m+1, $y+1900); # errechnet wieviel Tage der gegebene Monat hat eval { timelocal(0, 0, 0, $dim, $m, $y) } or do { $state = (split(" at", $@))[0]; $errstate = 1; @@ -3178,6 +3178,21 @@ sub delReadingFromBlocking { return 1; } +################################################################ +# errechnet wieviel Tage ein gegebener Monat eines +# bestimmten Jahres hat +# $m: realer Monat (1..12) +# $y: reales Jahr (2020) +################################################################ +sub daysInMonth { + my $m = shift; + my $y = shift; + + my $dim = $m-2?30+($m*3%7<4):28+!($y%4||$y%400*!($y%100)); + +return $dim; +} + ################################################################ # Timestamp korrigieren ################################################################