diff --git a/FHEM/90_at.pm b/FHEM/90_at.pm index 0cfa9f19c..b1e4516a9 100755 --- a/FHEM/90_at.pm +++ b/FHEM/90_at.pm @@ -4,6 +4,7 @@ package main; use strict; use warnings; +use POSIX; use Time::HiRes qw(gettimeofday); ##################################### @@ -35,7 +36,7 @@ at_SecondsTillTomorrow($) # 86400, if tomorrow is no DST change if(!$at_stt{$dayHour}) { my @l1 = localtime($t); my @l2 = localtime($t+86400); - $at_stt{$dayHour} = 86400+($l1[2]-$l2[2])*3600; + $at_stt{$dayHour} = 86400+($l1[8]-$l2[8])*3600; } return $at_stt{$dayHour}; @@ -74,14 +75,20 @@ at_Define($$) my $ot = $data{AT_TRIGGERTIME} ? $data{AT_TRIGGERTIME} : gettimeofday(); $ot = int($ot) if(!$rel); # No way to specify subseconds - my @lt = localtime($ot); my $nt = $ot; - $nt -= ($lt[2]*3600+$lt[1]*60+$lt[0]) # Midnight for absolute time - if($rel ne "+"); - $nt += ($hr*3600+$min*60+$sec); # Plus relative time - $nt += at_SecondsTillTomorrow($nt) if($ot >= $nt); # Do it tomorrow... - @lt = localtime($nt); + if($rel eq "+") { + $nt += ($hr*3600+$min*60+$sec); # Relative time + + } else { + my @lt = localtime($ot); + ($lt[2], $lt[1], $lt[0]) = ($hr+0, $min+0, $sec+0); + $nt = mktime(@lt[0..6]); + $nt += at_SecondsTillTomorrow($nt) if($ot >= $nt); # Do it tomorrow... + + } + + my @lt = localtime($nt); my $ntm = sprintf("%02d:%02d:%02d", $lt[2], $lt[1], $lt[0]); if($rep) { # Setting the number of repetitions $cnt =~ s/[{}]//g;