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
This commit is contained in:
rudolfkoenig 2015-10-25 11:58:17 +00:00
parent e9d9973531
commit 7f36b2c7c6

View File

@ -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;