suchen und ersetzen der Sonderzeichen
This commit is contained in:
parent
a19cd6cdf3
commit
2150a1c052
@ -215,8 +215,8 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
# print Dumper $data; ## für Debugging
|
# print Dumper $data; ## für Debugging
|
||||||
|
|
||||||
$self->{cached}->{current_date_time} =
|
$self->{cached}->{current_date_time} =
|
||||||
encode_utf8(strftime( "%a, %e %b %Y %H:%M",
|
strftimeWrapper( "%a, %e %b %Y %H:%M",
|
||||||
localtime( $self->{fetchTime} ) ));
|
localtime( $self->{fetchTime} ) );
|
||||||
$self->{cached}->{timezone} = $data->{timezone};
|
$self->{cached}->{timezone} = $data->{timezone};
|
||||||
$self->{cached}->{license}{text} =
|
$self->{cached}->{license}{text} =
|
||||||
$data->{flags}->{'meteoalarm-license'};
|
$data->{flags}->{'meteoalarm-license'};
|
||||||
@ -253,10 +253,10 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
'ozone' => $data->{currently}->{ozone},
|
'ozone' => $data->{currently}->{ozone},
|
||||||
'code' => $codes{ $data->{currently}->{icon} },
|
'code' => $codes{ $data->{currently}->{icon} },
|
||||||
'iconAPI' => $data->{currently}->{icon},
|
'iconAPI' => $data->{currently}->{icon},
|
||||||
'pubDate' => encode_utf8(strftime(
|
'pubDate' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime( $data->{currently}->{'time'} )
|
localtime( $data->{currently}->{'time'} )
|
||||||
)),
|
),
|
||||||
'precipProbability' => $data->{currently}->{precipProbability} * 100,
|
'precipProbability' => $data->{currently}->{precipProbability} * 100,
|
||||||
'apparentTemperature' => int(
|
'apparentTemperature' => int(
|
||||||
sprintf(
|
sprintf(
|
||||||
@ -277,12 +277,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{daily} },
|
@{ $self->{cached}->{forecast}->{daily} },
|
||||||
{
|
{
|
||||||
'pubDate' => encode_utf8(strftime(
|
'pubDate' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{'time'}
|
$data->{daily}->{data}->[$i]->{'time'}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'day_of_week' => strftime(
|
'day_of_week' => strftime(
|
||||||
"%a",
|
"%a",
|
||||||
localtime(
|
localtime(
|
||||||
@ -304,49 +304,49 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureLow} ) + 0.5
|
->{temperatureLow} ) + 0.5
|
||||||
),
|
),
|
||||||
'tempLowTime' => encode_utf8(strftime(
|
'tempLowTime' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureLowTime}
|
->{temperatureLowTime}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'tempHigh' => int(
|
'tempHigh' => int(
|
||||||
sprintf( "%.1f",
|
sprintf( "%.1f",
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureHigh} ) + 0.5
|
->{temperatureHigh} ) + 0.5
|
||||||
),
|
),
|
||||||
'tempHighTime' => encode_utf8(strftime(
|
'tempHighTime' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureHighTime}
|
->{temperatureHighTime}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'apparentTempLow' => int(
|
'apparentTempLow' => int(
|
||||||
sprintf( "%.1f",
|
sprintf( "%.1f",
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{apparentTemperatureLow} ) + 0.5
|
->{apparentTemperatureLow} ) + 0.5
|
||||||
),
|
),
|
||||||
'apparentTempLowTime' => encode_utf8(strftime(
|
'apparentTempLowTime' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{apparentTemperatureLowTime}
|
->{apparentTemperatureLowTime}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'apparentTempHigh' => int(
|
'apparentTempHigh' => int(
|
||||||
sprintf( "%.1f",
|
sprintf( "%.1f",
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{apparentTemperatureHigh} ) + 0.5
|
->{apparentTemperatureHigh} ) + 0.5
|
||||||
),
|
),
|
||||||
'apparentTempHighTime' => encode_utf8(strftime(
|
'apparentTempHighTime' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{apparentTemperatureHighTime}
|
->{apparentTemperatureHighTime}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'code' =>
|
'code' =>
|
||||||
$codes{ $data->{daily}->{data}->[$i]->{icon} },
|
$codes{ $data->{daily}->{data}->[$i]->{icon} },
|
||||||
'iconAPI' => $data->{daily}->{data}->[$i]->{icon},
|
'iconAPI' => $data->{daily}->{data}->[$i]->{icon},
|
||||||
@ -356,12 +356,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
'ozone' => $data->{daily}->{data}->[$i]->{ozone},
|
'ozone' => $data->{daily}->{data}->[$i]->{ozone},
|
||||||
'uvIndex' =>
|
'uvIndex' =>
|
||||||
$data->{daily}->{data}->[$i]->{uvIndex},
|
$data->{daily}->{data}->[$i]->{uvIndex},
|
||||||
'uvIndexTime' => encode_utf8(strftime(
|
'uvIndexTime' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{uvIndexTime}
|
$data->{daily}->{data}->[$i]->{uvIndexTime}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'dewPoint' => int(
|
'dewPoint' => int(
|
||||||
sprintf( "%.1f",
|
sprintf( "%.1f",
|
||||||
$data->{daily}->{data}->[$i]->{dewPoint} )
|
$data->{daily}->{data}->[$i]->{dewPoint} )
|
||||||
@ -388,26 +388,26 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
($data->{daily}->{data}->[$i]->{windGust} * 3.6) )
|
($data->{daily}->{data}->[$i]->{windGust} * 3.6) )
|
||||||
+ 0.5
|
+ 0.5
|
||||||
),
|
),
|
||||||
'windGustTime' => encode_utf8(strftime(
|
'windGustTime' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{windGustTime}
|
$data->{daily}->{data}->[$i]->{windGustTime}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'moonPhase' =>
|
'moonPhase' =>
|
||||||
$data->{daily}->{data}->[$i]->{moonPhase},
|
$data->{daily}->{data}->[$i]->{moonPhase},
|
||||||
'sunsetTime' => encode_utf8(strftime(
|
'sunsetTime' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{sunsetTime}
|
$data->{daily}->{data}->[$i]->{sunsetTime}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'sunriseTime' => encode_utf8(strftime(
|
'sunriseTime' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{daily}->{data}->[$i]->{sunriseTime}
|
$data->{daily}->{data}->[$i]->{sunriseTime}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'pressure' => int(
|
'pressure' => int(
|
||||||
sprintf( "%.1f",
|
sprintf( "%.1f",
|
||||||
$data->{daily}->{data}->[$i]->{pressure} )
|
$data->{daily}->{data}->[$i]->{pressure} )
|
||||||
@ -425,7 +425,7 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
$self->{cached}->{forecast}->{daily}[$i]{precipIntensity} = ( defined($data->{daily}->{data}->[$i]->{precipIntensity}) ? $data->{daily}->{data}->[$i]->{precipIntensity} : '-' );
|
$self->{cached}->{forecast}->{daily}[$i]{precipIntensity} = ( defined($data->{daily}->{data}->[$i]->{precipIntensity}) ? $data->{daily}->{data}->[$i]->{precipIntensity} : '-' );
|
||||||
$self->{cached}->{forecast}->{daily}[$i]{precipProbability} = ( defined($data->{daily}->{data}->[$i]->{precipProbability}) ? $data->{daily}->{data}->[$i]->{precipProbability} * 100 : '-' );
|
$self->{cached}->{forecast}->{daily}[$i]{precipProbability} = ( defined($data->{daily}->{data}->[$i]->{precipProbability}) ? $data->{daily}->{data}->[$i]->{precipProbability} * 100 : '-' );
|
||||||
$self->{cached}->{forecast}->{daily}[$i]{precipType} = ( defined($data->{daily}->{data}->[$i]->{precipType}) ? $data->{daily}->{data}->[$i]->{precipType} : '-' );
|
$self->{cached}->{forecast}->{daily}[$i]{precipType} = ( defined($data->{daily}->{data}->[$i]->{precipType}) ? $data->{daily}->{data}->[$i]->{precipType} : '-' );
|
||||||
$self->{cached}->{forecast}->{daily}[$i]{precipIntensityMaxTime} = ( defined($data->{daily}->{data}->[$i]->{precipIntensityMaxTime}) ? encode_utf8(strftime("%a, %e %b %Y %H:%M",localtime($data->{daily}->{data}->[$i]->{precipIntensityMaxTime}) )) : '-' );
|
$self->{cached}->{forecast}->{daily}[$i]{precipIntensityMaxTime} = ( defined($data->{daily}->{data}->[$i]->{precipIntensityMaxTime}) ? strftimeWrapper("%a, %e %b %Y %H:%M",localtime($data->{daily}->{data}->[$i]->{precipIntensityMaxTime}) ) : '-' );
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -441,12 +441,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{hourly} },
|
@{ $self->{cached}->{forecast}->{hourly} },
|
||||||
{
|
{
|
||||||
'pubDate' => encode_utf8(strftime(
|
'pubDate' => strftimeWrapper(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
$data->{hourly}->{data}->[$i]->{'time'}
|
$data->{hourly}->{data}->[$i]->{'time'}
|
||||||
)
|
)
|
||||||
)),
|
),
|
||||||
'day_of_week' => strftime(
|
'day_of_week' => strftime(
|
||||||
"%a, %H:%M",
|
"%a, %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
@ -522,7 +522,7 @@ sub _ErrorHandling($$) {
|
|||||||
my ( $self, $err ) = @_;
|
my ( $self, $err ) = @_;
|
||||||
|
|
||||||
$self->{cached}->{current_date_time} =
|
$self->{cached}->{current_date_time} =
|
||||||
encode_utf8(strftime( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) )),
|
strftimeWrapper( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ),
|
||||||
$self->{cached}->{status} = $err;
|
$self->{cached}->{status} = $err;
|
||||||
$self->{cached}->{validity} = 'stale';
|
$self->{cached}->{validity} = 'stale';
|
||||||
}
|
}
|
||||||
@ -543,6 +543,25 @@ sub _CreateForecastRef($) {
|
|||||||
return $forecastRef;
|
return $forecastRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub strftimeWrapper(@) {
|
||||||
|
my $string = POSIX::strftime(@_);
|
||||||
|
|
||||||
|
$string =~ s/\xe4/ä/g;
|
||||||
|
$string =~ s/\xc4/Ä/g;
|
||||||
|
$string =~ s/\xf6/ö/g;
|
||||||
|
$string =~ s/\xd6/Ö/g;
|
||||||
|
$string =~ s/\xfc/ü/g;
|
||||||
|
$string =~ s/\xdc/Ü/g;
|
||||||
|
$string =~ s/\xdf/ß/g;
|
||||||
|
$string =~ s/\xdf/ß/g;
|
||||||
|
$string =~ s/\xe1/á/g;
|
||||||
|
$string =~ s/\xe9/é/g;
|
||||||
|
$string =~ s/\xc1/Á/g;
|
||||||
|
$string =~ s/\xc9/É/g;
|
||||||
|
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user