fix bug then month are umlauts
This commit is contained in:
parent
9f4d28fffa
commit
832843bf18
@ -44,7 +44,7 @@ eval "use Encode qw(encode_utf8);1" or $missingModul .= "Encode ";
|
|||||||
# use Data::Dumper; # for Debug only
|
# use Data::Dumper; # for Debug only
|
||||||
## API URL
|
## API URL
|
||||||
use constant URL => 'https://api.darksky.net/forecast/';
|
use constant URL => 'https://api.darksky.net/forecast/';
|
||||||
use constant VERSION => '0.2.4';
|
use constant VERSION => '0.2.5';
|
||||||
|
|
||||||
my %codes = (
|
my %codes = (
|
||||||
'clear-day' => 32,
|
'clear-day' => 32,
|
||||||
@ -209,8 +209,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} =
|
||||||
strftime( "%a, %e %b %Y %H:%M",
|
encode_utf8(strftime( "%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'};
|
||||||
@ -247,10 +247,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' => strftime(
|
'pubDate' => encode_utf8(strftime(
|
||||||
"%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(
|
||||||
@ -271,12 +271,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{daily} },
|
@{ $self->{cached}->{forecast}->{daily} },
|
||||||
{
|
{
|
||||||
'pubDate' => strftime(
|
'pubDate' => encode_utf8(strftime(
|
||||||
"%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(
|
||||||
@ -298,49 +298,49 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
$data->{daily}->{data}->[$i]
|
$data->{daily}->{data}->[$i]
|
||||||
->{temperatureLow} ) + 0.5
|
->{temperatureLow} ) + 0.5
|
||||||
),
|
),
|
||||||
'tempLowTime' => strftime(
|
'tempLowTime' => encode_utf8(strftime(
|
||||||
"%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' => strftime(
|
'tempHighTime' => encode_utf8(strftime(
|
||||||
"%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' => strftime(
|
'apparentTempLowTime' => encode_utf8(strftime(
|
||||||
"%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' => strftime(
|
'apparentTempHighTime' => encode_utf8(strftime(
|
||||||
"%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},
|
||||||
@ -350,12 +350,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' => strftime(
|
'uvIndexTime' => encode_utf8(strftime(
|
||||||
"%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} )
|
||||||
@ -382,26 +382,26 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
($data->{daily}->{data}->[$i]->{windGust} * 3.6) )
|
($data->{daily}->{data}->[$i]->{windGust} * 3.6) )
|
||||||
+ 0.5
|
+ 0.5
|
||||||
),
|
),
|
||||||
'windGustTime' => strftime(
|
'windGustTime' => encode_utf8(strftime(
|
||||||
"%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' => strftime(
|
'sunsetTime' => encode_utf8(strftime(
|
||||||
"%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' => strftime(
|
'sunriseTime' => encode_utf8(strftime(
|
||||||
"%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} )
|
||||||
@ -419,7 +419,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}) ? 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}) ? encode_utf8(strftime("%a, %e %b %Y %H:%M",localtime($data->{daily}->{data}->[$i]->{precipIntensityMaxTime}) )) : '-' );
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -435,12 +435,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{hourly} },
|
@{ $self->{cached}->{forecast}->{hourly} },
|
||||||
{
|
{
|
||||||
'pubDate' => strftime(
|
'pubDate' => encode_utf8(strftime(
|
||||||
"%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(
|
||||||
@ -516,7 +516,7 @@ sub _ErrorHandling($$) {
|
|||||||
my ( $self, $err ) = @_;
|
my ( $self, $err ) = @_;
|
||||||
|
|
||||||
$self->{cached}->{current_date_time} =
|
$self->{cached}->{current_date_time} =
|
||||||
strftime( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ),
|
encode_utf8(strftime( "%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';
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ eval "use Encode qw(encode_utf8);1" or $missingModul .= "Encode ";
|
|||||||
# use Data::Dumper; # for Debug only
|
# use Data::Dumper; # for Debug only
|
||||||
## API URL
|
## API URL
|
||||||
use constant URL => 'https://api.openweathermap.org/data/2.5/';
|
use constant URL => 'https://api.openweathermap.org/data/2.5/';
|
||||||
use constant VERSION => '0.2.2';
|
use constant VERSION => '0.2.3';
|
||||||
## URL . 'weather?' for current data
|
## URL . 'weather?' for current data
|
||||||
## URL . 'forecast?' for forecast data
|
## URL . 'forecast?' for forecast data
|
||||||
|
|
||||||
@ -264,8 +264,8 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
# print 'Response: ' . Dumper $data;
|
# print 'Response: ' . Dumper $data;
|
||||||
###### Ab hier wird die ResponseHash Referenze für die Rückgabe zusammen gestellt
|
###### Ab hier wird die ResponseHash Referenze für die Rückgabe zusammen gestellt
|
||||||
$self->{cached}->{current_date_time} =
|
$self->{cached}->{current_date_time} =
|
||||||
strftime( "%a, %e %b %Y %H:%M",
|
encode_utf8(strftime( "%a, %e %b %Y %H:%M",
|
||||||
localtime( $self->{fetchTime} ) );
|
localtime( $self->{fetchTime} ) ));
|
||||||
|
|
||||||
if ( $self->{endpoint} eq 'weather' ) {
|
if ( $self->{endpoint} eq 'weather' ) {
|
||||||
$self->{cached}->{country} = $data->{sys}->{country};
|
$self->{cached}->{country} = $data->{sys}->{country};
|
||||||
@ -311,18 +311,18 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
int( sprintf( "%.1f", $data->{visibility} ) + 0.5 ),
|
int( sprintf( "%.1f", $data->{visibility} ) + 0.5 ),
|
||||||
'code' => $codes{ $data->{weather}->[0]->{id} },
|
'code' => $codes{ $data->{weather}->[0]->{id} },
|
||||||
'iconAPI' => $data->{weather}->[0]->{icon},
|
'iconAPI' => $data->{weather}->[0]->{icon},
|
||||||
'sunsetTime' => strftime(
|
'sunsetTime' => encode_utf8(strftime(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime( $data->{sys}->{sunset} )
|
localtime( $data->{sys}->{sunset} )
|
||||||
),
|
)),
|
||||||
'sunriseTime' => strftime(
|
'sunriseTime' => encode_utf8(strftime(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime( $data->{sys}->{sunrise} )
|
localtime( $data->{sys}->{sunrise} )
|
||||||
),
|
)),
|
||||||
'pubDate' => strftime(
|
'pubDate' => encode_utf8(strftime(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime( $data->{dt} )
|
localtime( $data->{dt} )
|
||||||
),
|
)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,12 +338,12 @@ sub _ProcessingRetrieveData($$) {
|
|||||||
push(
|
push(
|
||||||
@{ $self->{cached}->{forecast}->{hourly} },
|
@{ $self->{cached}->{forecast}->{hourly} },
|
||||||
{
|
{
|
||||||
'pubDate' => strftime(
|
'pubDate' => encode_utf8(strftime(
|
||||||
"%a, %e %b %Y %H:%M",
|
"%a, %e %b %Y %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
( $data->{list}->[$i]->{dt} ) - 3600
|
( $data->{list}->[$i]->{dt} ) - 3600
|
||||||
)
|
)
|
||||||
),
|
)),
|
||||||
'day_of_week' => strftime(
|
'day_of_week' => strftime(
|
||||||
"%a, %H:%M",
|
"%a, %H:%M",
|
||||||
localtime(
|
localtime(
|
||||||
@ -472,7 +472,7 @@ sub _ErrorHandling($$) {
|
|||||||
my ( $self, $err ) = @_;
|
my ( $self, $err ) = @_;
|
||||||
|
|
||||||
$self->{cached}->{current_date_time} =
|
$self->{cached}->{current_date_time} =
|
||||||
strftime( "%a, %e %b %Y %H:%M", localtime( $self->{fetchTime} ) ),
|
encode_utf8(strftime( "%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';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user