2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

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
This commit is contained in:
nasseeder1 2018-01-04 19:50:07 +00:00
parent a639aa0db8
commit 5ab2c2fd81
2 changed files with 9 additions and 7 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # 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_PWM: new attribute "restoreOnStartup"
- feature: 20_FRM_OUT: new attributes "activeLow" and "valueMode" - feature: 20_FRM_OUT: new attributes "activeLow" and "valueMode"
- feature: 10_FRM: SerialFirmata support - feature: 10_FRM: SerialFirmata support

View File

@ -37,6 +37,7 @@
########################################################################################################################### ###########################################################################################################################
# Versions History: # 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.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, # 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 # bugfix connection check is running after restart allthough dev is disabled
@ -273,7 +274,7 @@ use Encode qw(encode_utf8);
sub DbRep_Main($$;$); sub DbRep_Main($$;$);
my $DbRepVersion = "7.2.0"; my $DbRepVersion = "7.2.1";
my %dbrep_col = ("DEVICE" => 64, my %dbrep_col = ("DEVICE" => 64,
"TYPE" => 64, "TYPE" => 64,
@ -1310,7 +1311,7 @@ sub createTimeArray($$$) {
if (AttrVal($name, "timestamp_begin", "") eq "previous_month_begin" || if (AttrVal($name, "timestamp_begin", "") eq "previous_month_begin" ||
AttrVal($name, "timestamp_end", "") eq "previous_month_begin") { AttrVal($name, "timestamp_end", "") eq "previous_month_begin") {
$ryear = ($mon-1<0)?$year-1:$year; $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"); $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"); $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" || if (AttrVal($name, "timestamp_begin", "") eq "previous_month_end" ||
AttrVal($name, "timestamp_end", "") eq "previous_month_end") { AttrVal($name, "timestamp_end", "") eq "previous_month_end") {
$ryear = ($mon-1<0)?$year-1:$year; $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)); $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"); $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"); $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) { if($rmday<1) {
$rmon--; $rmon--;
if ($rmon<0) { if ($rmon<0) {
$rmon=12; $rmon=11;
$ryear--; $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) $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) { if($rmday<1) {
$rmon--; $rmon--;
if ($rmon<0) { if ($rmon<0) {
$rmon=12; $rmon=11;
$ryear--; $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) $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) { if($rmday<1) {
$rmon--; $rmon--;
if ($rmon<0) { if ($rmon<0) {
$rmon=12; $rmon=11;
$ryear--; $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) $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) { if($rmday<1) {
$rmon--; $rmon--;
if ($rmon<0) { if ($rmon<0) {
$rmon=12; $rmon=11;
$ryear--; $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) $rmday = $rmon-1?30+(($rmon+1)*3%7<4):28+!($ryear%4||$ryear%400*!($ryear%100)); # Achtung: Monat als 1...12 (statt 0...11)