############################################## # $Id$ package main; use strict; use warnings; use Time::HiRes qw(gettimeofday); ##################################### sub at_Initialize($) { my ($hash) = @_; $hash->{DefFn} = "at_Define"; $hash->{UndefFn} = "at_Undef"; $hash->{AttrFn} = "at_Attr"; $hash->{StateFn} = "at_State"; $hash->{AttrList} = "disable:0,1 skip_next:0,1 alignTime"; } my $oldattr; my $at_stt_sec; my $at_stt_day; sub at_SecondsTillTomorrow($) # 86400, if tomorrow is no DST change { my $t = shift; my $day = int($t/86400); if(!$at_stt_day || $day != $at_stt_day) { my $t = $day*86400+12*3600; my @l1 = localtime($t); my @l2 = localtime($t+86400); $at_stt_sec = 86400+ ($l1[2]-$l2[2])*3600+ ($l1[1]-$l2[1])*60; $at_stt_day = $day; } return $at_stt_sec; } ##################################### sub at_Define($$) { my ($hash, $def) = @_; my ($name, undef, $tm, $command) = split("[ \t]+", $def, 4); if(!$command) { if($hash->{OLDDEF}) { # Called from modify, where command is optional RemoveInternalTimer($hash); (undef, $command) = split("[ \t]+", $hash->{OLDDEF}, 2); $hash->{DEF} = "$tm $command"; } else { return "Usage: define at "; } } return "Wrong timespec, use \"[+][*[{count}]]