From 5ab2c2fd81ca55b13d0d91969a9237f0e01ee6bf Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Thu, 4 Jan 2018 19:50:07 +0000 Subject: [PATCH] 93_DbRep: fix "month out of range" that causes fhem crash git-svn-id: https://svn.fhem.de/fhem/trunk@15780 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/93_DbRep.pm | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 09b02a597..c9ff0f674 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - bugfix: 93_DbRep: fix "month out of range" that causes fhem crash - feature: 20_FRM_PWM: new attribute "restoreOnStartup" - feature: 20_FRM_OUT: new attributes "activeLow" and "valueMode" - feature: 10_FRM: SerialFirmata support diff --git a/fhem/FHEM/93_DbRep.pm b/fhem/FHEM/93_DbRep.pm index 7800741bb..e89dfec4c 100644 --- a/fhem/FHEM/93_DbRep.pm +++ b/fhem/FHEM/93_DbRep.pm @@ -37,6 +37,7 @@ ########################################################################################################################### # Versions History: # +# 7.2.1 04.01.2018 bugfix month out of range that causes fhem crash # 7.2.0 27.12.2017 new attribute "seqDoubletsVariance" # 7.1.0 22.12.2017 new attribute timeYearPeriod for reports correspondig to e.g. electricity billing, # bugfix connection check is running after restart allthough dev is disabled @@ -273,7 +274,7 @@ use Encode qw(encode_utf8); sub DbRep_Main($$;$); -my $DbRepVersion = "7.2.0"; +my $DbRepVersion = "7.2.1"; my %dbrep_col = ("DEVICE" => 64, "TYPE" => 64, @@ -1310,7 +1311,7 @@ sub createTimeArray($$$) { if (AttrVal($name, "timestamp_begin", "") eq "previous_month_begin" || AttrVal($name, "timestamp_end", "") eq "previous_month_begin") { $ryear = ($mon-1<0)?$year-1:$year; - $rmon = ($mon-1<0)?12:$mon-1; + $rmon = ($mon-1<0)?11:$mon-1; $tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_month_begin"); $tsend = strftime "%Y-%m-%d %T",localtime(timelocal(0,0,0,1,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_month_begin"); } @@ -1318,7 +1319,7 @@ sub createTimeArray($$$) { if (AttrVal($name, "timestamp_begin", "") eq "previous_month_end" || AttrVal($name, "timestamp_end", "") eq "previous_month_end") { $ryear = ($mon-1<0)?$year-1:$year; - $rmon = ($mon-1<0)?12:$mon-1; + $rmon = ($mon-1<0)?11:$mon-1; $dim = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100)); $tsbegin = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$dim,$rmon,$ryear)) if(AttrVal($name, "timestamp_begin", "") eq "previous_month_end"); $tsend = strftime "%Y-%m-%d %T",localtime(timelocal(59,59,23,$dim,$rmon,$ryear)) if(AttrVal($name, "timestamp_end", "") eq "previous_month_end"); @@ -1400,7 +1401,7 @@ sub createTimeArray($$$) { if($rmday<1) { $rmon--; if ($rmon<0) { - $rmon=12; + $rmon=11; $ryear--; } $rmday = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100)); # Achtung: Monat als 1...12 (statt 0...11) @@ -1417,7 +1418,7 @@ sub createTimeArray($$$) { if($rmday<1) { $rmon--; if ($rmon<0) { - $rmon=12; + $rmon=11; $ryear--; } $rmday = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100)); # Achtung: Monat als 1...12 (statt 0...11) @@ -1450,7 +1451,7 @@ sub createTimeArray($$$) { if($rmday<1) { $rmon--; if ($rmon<0) { - $rmon=12; + $rmon=11; $ryear--; } $rmday = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100)); # Achtung: Monat als 1...12 (statt 0...11) @@ -1472,7 +1473,7 @@ sub createTimeArray($$$) { if($rmday<1) { $rmon--; if ($rmon<0) { - $rmon=12; + $rmon=11; $ryear--; } $rmday = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100)); # Achtung: Monat als 1...12 (statt 0...11)