From 7f36b2c7c69fb9bb8af3bf8cc9e8766e0af366c8 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Sun, 25 Oct 2015 11:58:17 +0000 Subject: [PATCH] 90_at.pm: fix DST change-bug (Forum #42920) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@9660 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/90_at.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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;