change intern IsWe to global fhem.pl IsWe Fn

This commit is contained in:
Marko Oldenburg 2019-03-25 11:23:49 +01:00
parent 1c979f1b24
commit 5317e40bdf

View File

@ -2539,38 +2539,40 @@ sub TimeMin2Sec($) {
} }
sub IsWe() { sub IsWe() {
my ( undef, undef, undef, undef, undef, undef, $wday, undef, undef ) = # my ( undef, undef, undef, undef, undef, undef, $wday, undef, undef ) =
localtime( gettimeofday() ); # localtime( gettimeofday() );
my $we = ( ( $wday == 0 || $wday == 6 ) ? 1 : 0 ); # my $we = ( ( $wday == 0 || $wday == 6 ) ? 1 : 0 );
#
if ( !$we ) { # if ( !$we ) {
foreach my $h2we ( split( ',', AttrVal( 'global', 'holiday2we', '' ) ) ) # foreach my $h2we ( split( ',', AttrVal( 'global', 'holiday2we', '' ) ) )
{ # {
my ( $a, $b ) = # my ( $a, $b ) =
ReplaceEventMap( $h2we, [ $h2we, ReadingsVal($h2we,'state',0) ], 0 ); # ReplaceEventMap( $h2we, [ $h2we, ReadingsVal($h2we,'state',0) ], 0 );
$we = 1 if ( $b && $b ne 'none' ); # $we = 1 if ( $b && $b ne 'none' );
} # }
} # }
my $we = main::IsWe();
return $we; return $we;
} }
sub IsWeTomorrow() { sub IsWeTomorrow() {
my ( undef, undef, undef, undef, undef, undef, $wday, undef, undef ) = # my ( undef, undef, undef, undef, undef, undef, $wday, undef, undef ) =
localtime( gettimeofday() ); # localtime( gettimeofday() );
my $we = ( # my $we = (
( ( ( $wday + 1 == 7 ? 0 : $wday + 1 ) ) == 0 || ( $wday + 1 ) == 6 ) # ( ( ( $wday + 1 == 7 ? 0 : $wday + 1 ) ) == 0 || ( $wday + 1 ) == 6 )
? 1 # ? 1
: 0 # : 0
); # );
#
if ( !$we ) { # if ( !$we ) {
foreach my $h2we ( split( ',', AttrVal( 'global', 'holiday2we', '' ) ) ) # foreach my $h2we ( split( ',', AttrVal( 'global', 'holiday2we', '' ) ) )
{ # {
my ( $a, $b ) = ReplaceEventMap( $h2we, # my ( $a, $b ) = ReplaceEventMap( $h2we,
[ $h2we, ReadingsVal( $h2we, 'tomorrow', 0 ) ], 0 ); # [ $h2we, ReadingsVal( $h2we, 'tomorrow', 0 ) ], 0 );
$we = 1 if ( $b && $b ne 'none' ); # $we = 1 if ( $b && $b ne 'none' );
} # }
} # }
my $we = main::IsWe('tomorrow');
return $we; return $we;
} }