From e19a7a87da2b6c8a454f361e94df5ed64f05de7c Mon Sep 17 00:00:00 2001 From: borisneubert Date: Sun, 15 Jun 2014 07:17:06 +0000 Subject: [PATCH] duration parsing of calendar events and evaluation of creation/modification times in 57_Calendar.pm fixed git-svn-id: https://svn.fhem.de/fhem/trunk@6116 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 3 ++- fhem/FHEM/57_Calendar.pm | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index aa1f5ae94..c993f20a6 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,7 +1,8 @@ # 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: duration parsing of calendar events in 57_Calendar.pm fixed - feature: LightScene: added followDevices attribute - - feature: non-blocking retrieval of data in 57_Weather.pm (Boris & herrmannj) + - feature: non-blocking retrieval of data in 59_Weather.pm (Boris & herrmannj) - feature: new modules 37_SHC.pm and 37_SHCdev.pm added (rr2000) - ad-hoc: (betateilchen) reverted 10_CUL_HM.pm to previous version 6096 diff --git a/fhem/FHEM/57_Calendar.pm b/fhem/FHEM/57_Calendar.pm index 0ef6334b0..7b5421ebd 100644 --- a/fhem/FHEM/57_Calendar.pm +++ b/fhem/FHEM/57_Calendar.pm @@ -292,8 +292,14 @@ sub d { } elsif($dw =~ m/(\d+)W$/) { $t+= 604800*$1; # weeks } - if($dt =~ m/^(\d+)H(\d+)M(\d+)S$/) { - $t+= $1*3600+$2*60+$3; + if($dt =~ m/(\d+)H/) { + $t+= $1*3600; + } + if($dt =~ m/(\d+)M/) { + $t+= $1*60; + } + if($dt =~ m/(\d+)S/) { + $t+= $1; } $t*= $sign; #main::Debug "sign: $sign dw: $dw dt: $dt t= $t"; @@ -335,7 +341,14 @@ sub fromVEvent { } elsif(defined($vevent->value("DURATION"))) { $self->{end}= $self->{start} + d($vevent->value("DURATION")); } - $self->{lastModified}= tm($vevent->value("LAST-MODIFIED")); + # we take the creation time if the last modification time is unavailable + if(defined($vevent->value("LAST-MODIFIED"))) { + $self->{lastModified}= tm($vevent->value("LAST-MODIFIED")); + #main::Debug "LAST-MOD: $self->{lastModified} "; + } else { + $self->{lastModified}= tm($vevent->value("DTSTAMP")); + #main::Debug "DTSTAMP: $self->{lastModified} "; + } $self->{summary}= $vevent->value("SUMMARY"); $self->{location}= $vevent->value("LOCATION");