2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-07 16:59:18 +00:00

CTZ.pm: publish func reqModFail

git-svn-id: https://svn.fhem.de/fhem/trunk@25822 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2022-03-13 07:52:58 +00:00
parent b211217162
commit 6451c65699

View File

@ -26,6 +26,7 @@
######################################################################################################################### #########################################################################################################################
# Version History # Version History
# 0.0.3 13.03.2022 publish func reqModFail
# 0.0.2 12.03.2022 check required Perl modules # 0.0.2 12.03.2022 check required Perl modules
# 0.0.1 10.03.2022 initial # 0.0.1 10.03.2022 initial
@ -48,6 +49,7 @@ use Exporter ('import');
our @EXPORT_OK = qw( our @EXPORT_OK = qw(
convertTimeZone convertTimeZone
getTZNames getTZNames
reqModFail
); );
our %EXPORT_TAGS = (all => [@EXPORT_OK]); our %EXPORT_TAGS = (all => [@EXPORT_OK]);
@ -84,8 +86,8 @@ sub convertTimeZone {
return $err; return $err;
} }
my $abs = modabsent(); my $rmf = reqModFail();
return $abs if($abs); return $rmf if($rmf);
my $name = $paref->{name} // $pkg; my $name = $paref->{name} // $pkg;
my $dtstring = $paref->{dtstring} // q{}; my $dtstring = $paref->{dtstring} // q{};
@ -133,8 +135,11 @@ return $valid;
############################################################################### ###############################################################################
sub getTZNames { sub getTZNames {
if(modabsent()) { my $rmf = reqModFail();
return [qw()]; if($rmf) {
$rmf = "ERROR - ".$rmf;
Log (1, "$pkg - $rmf");
return [($rmf)];
} }
my $atz = DateTime::TimeZone->all_names; my $atz = DateTime::TimeZone->all_names;
@ -145,14 +150,14 @@ return $atz;
############################################################################### ###############################################################################
# Check required Perl modules # Check required Perl modules
############################################################################### ###############################################################################
sub modabsent { sub reqModFail {
if ($abs0 || $abs1) { if ($abs0 || $abs1) {
$abs0 //= q{}; my @ma;
$abs1 //= q{}; push @ma, $abs0 if($abs0);
push @ma, $abs1 if($abs1);
my $err = qq{the perl module "$abs0" and/or "$abs1" is not installed}; my $err = "required perl module not installed: ".join ", ", @ma;
Log (1, "$pkg - ERROR - $err");
return $err; return $err;
} }