in reply to Re^2: Efficiency of indoor grow light timer
in thread Efficiency of indoor grow light timer
Edit: Removed C&P remnantuse 5.24.1; use feature qw:signatures:; no warnings qw:experimental:; my @off_from = (22, 0, 0); #22:00:00 my @off_until = (08, 0, 1); #08:00:00 sub cmpt ( $a, $b ) { for ( 0 .. 2 ){ return $a->[$_] <=> $b->[$_] if $a->[$_] != $b->[$_] ; } return 0; } sub is_nighttime( $now ) { my @now = @{$now} || (localtime(time))[2,1,0]; if ( cmpt( \@off_from, \@off_until ) == 1 ) { # over midnight return cmpt(\@now, \@off_from) == 1 || cmpt( \@now, \@off_unti +l ) == -1; } else { # all same day return cmpt(\@now, \@off_from) == 1 && cmpt( \@now, \@off_unti +l ) == -1; } return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Efficiency of indoor grow light timer
by stevieb (Canon) on Nov 12, 2017 at 21:39 UTC | |
by holli (Abbot) on Nov 12, 2017 at 21:43 UTC | |
by stevieb (Canon) on Nov 12, 2017 at 21:50 UTC | |
|
Re^4: Efficiency of indoor grow light timer
by stevieb (Canon) on Dec 12, 2017 at 00:11 UTC |