2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-18 12:06:04 +00:00

90_at.pm: function may return absolute dates (Forum #116377)

git-svn-id: https://svn.fhem.de/fhem/trunk@23278 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-12-02 13:12:19 +00:00
parent f09c3ace72
commit 013745c067
2 changed files with 16 additions and 2 deletions

View File

@ -74,7 +74,21 @@ at_Define($$)
} else {
($err, $hr, $min, $sec, $fn) = GetTimeSpec($tspec);
return $err if($err);
if($err) { # $fn contains the result, try again
my $ntspec = $fn;
$fn = undef;
if($ntspec =~ m/^\d{10}$/) {
$abstime = $ntspec;
} elsif($ntspec =~ m/^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)$/) {
my ($y,$m,$d,$h,$m2,$s) = ($1,$2,$3,$4,$5,$6);
$abstime = mktime($s,$m2,$h,$d,$m-1,$y-1900, 0,0,-1);
} else {
return $err;
}
}
}
return "datespec is not allowed with + or *" if($abstime && ($rel || $rep));

View File

@ -3633,7 +3633,7 @@ GetTimeSpec($)
my ($err, $fn2);
($err, $hr, $min, $sec, $fn2) = GetTimeSpec($tspec);
return ("the function \"$fn\" must return a timespec and not $tspec.",
undef, undef, undef, undef) if($err);
undef, undef, undef, $tspec) if($err);
} else {
return ("Wrong timespec $tspec: either HH:MM:SS or {perlcode}",