diff --git a/59_Weather.pm b/59_Weather.pm index 2d1a74a..81d9858 100755 --- a/59_Weather.pm +++ b/59_Weather.pm @@ -138,7 +138,7 @@ sub Weather_Initialize($) { $hash->{UndefFn} = "Weather_Undef"; $hash->{GetFn} = "Weather_Get"; $hash->{SetFn} = "Weather_Set"; - $hash->{AttrList}= "disable " . $readingFnAttributes; + $hash->{AttrList}= "disable:0,1 " . $readingFnAttributes; $hash->{NotifyFn}= "Weather_Notify"; #Weather_DebugCodes('de'); @@ -416,7 +416,7 @@ sub Weather_WriteReadings($$) { my $wdir= degrees_to_direction($dataRef->{forecast}->{hourly}[$i-1]{wind_direction}, @directions_txt_i18n); readingsBulkUpdate($hash, $f . 'wind_condition', 'Wind: ' . $wdir . ' ' . $dataRef->{forecast}->{hourly}[$i-1]{wind_speed} . ' km/h'); } - # readingsBulkUpdate($hash, $f . 'day_of_week', $wdays_txt_i18n{substr($dataRef->{forecast}->{hourly}[$i-1]{date},0,3)}); + readingsBulkUpdate($hash, $f . 'day_of_week', ( length((split(',', $dataRef->{forecast}->{hourly}[$i-1]{pubDate}))[0]) > 2 ? $wdays_txt_i18n{substr($dataRef->{forecast}->{hourly}[$i-1]{pubDate},0,3)} : substr($dataRef->{forecast}->{hourly}[$i-1]{pubDate},0,2) ) ); } } @@ -444,7 +444,7 @@ sub Weather_WriteReadings($$) { my $wdir= degrees_to_direction($dataRef->{forecast}->{daily}[$i-1]{wind_direction}, @directions_txt_i18n); readingsBulkUpdate($hash, $f . 'wind_condition', 'Wind: ' . $wdir . ' ' . $dataRef->{forecast}->{daily}[$i-1]{wind_speed} . ' km/h'); } - # readingsBulkUpdate($hash, $f . 'day_of_week', $wdays_txt_i18n{substr($dataRef->{forecast}->{daily}[$i-1]{date},0,3)}); + readingsBulkUpdate($hash, $f . 'day_of_week', ( length((split(',', $dataRef->{forecast}->{daily}[$i-1]{pubDate}))[0]) > 2 ? $wdays_txt_i18n{substr($dataRef->{forecast}->{daily}[$i-1]{pubDate},0,3)} : substr($dataRef->{forecast}->{daily}[$i-1]{pubDate},0,2) ) ); } } } diff --git a/DarkSkyAPI.pm b/DarkSkyAPI.pm index 666ee3e..576784f 100644 --- a/DarkSkyAPI.pm +++ b/DarkSkyAPI.pm @@ -205,7 +205,7 @@ sub _ProcessingRetrieveData($$) { # print Dumper $data; ## für Debugging $self->{cached}->{current_date_time} = - strftime( "%a,%e %b %Y %H:%M %p", + strftime( "%a, %e %b %Y %H:%M %p", localtime( $self->{fetchTime} ) ); $self->{cached}->{timezone} = $data->{timezone}; $self->{cached}->{license}{text} = @@ -244,7 +244,7 @@ sub _ProcessingRetrieveData($$) { 'code' => $codes{ $data->{currently}->{icon} }, 'iconAPI' => $data->{currently}->{icon}, 'pubDate' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{currently}->{'time'} ) ), 'precipProbability' => $data->{currently}->{precipProbability}, @@ -267,14 +267,8 @@ sub _ProcessingRetrieveData($$) { push( @{ $self->{cached}->{forecast}->{daily} }, { - 'date' => strftime( - "%a, %d.%m.%Y", - localtime( - $data->{daily}->{data}->[$i]->{'time'} - ) - ), - 'day_of_week' => strftime( - "%a", + 'pubDate' => strftime( + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i]->{'time'} ) @@ -295,7 +289,7 @@ sub _ProcessingRetrieveData($$) { ->{temperatureMin} ) + 0.5 ), 'tempMinTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{temperatureMinTime} @@ -307,7 +301,7 @@ sub _ProcessingRetrieveData($$) { ->{temperatureMax} ) + 0.5 ), 'tempMaxTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{temperatureMaxTime} @@ -319,7 +313,7 @@ sub _ProcessingRetrieveData($$) { ->{temperatureLow} ) + 0.5 ), 'tempLowTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{temperatureLowTime} @@ -331,7 +325,7 @@ sub _ProcessingRetrieveData($$) { ->{temperatureHigh} ) + 0.5 ), 'tempHighTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{temperatureHighTime} @@ -343,7 +337,7 @@ sub _ProcessingRetrieveData($$) { ->{apparentTemperatureLow} ) + 0.5 ), 'apparentTempLowTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{apparentTemperatureLowTime} @@ -355,7 +349,7 @@ sub _ProcessingRetrieveData($$) { ->{apparentTemperatureHigh} ) + 0.5 ), 'apparentTempHighTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{apparentTemperatureHighTime} @@ -367,7 +361,7 @@ sub _ProcessingRetrieveData($$) { ->{apparentTemperatureMin} ) + 0.5 ), 'apparenttempMinTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{apparentTemperatureMinTime} @@ -379,7 +373,7 @@ sub _ProcessingRetrieveData($$) { ->{apparentTemperatureMax} ) + 0.5 ), 'apparenttempMaxTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{apparentTemperatureMaxTime} @@ -395,7 +389,7 @@ sub _ProcessingRetrieveData($$) { 'uvIndex' => $data->{daily}->{data}->[$i]->{uvIndex}, 'uvIndexTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i]->{uvIndexTime} ) @@ -406,7 +400,7 @@ sub _ProcessingRetrieveData($$) { $data->{daily}->{data}->[$i] ->{precipIntensityMax}, 'precipIntensityMaxTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i] ->{precipIntensityMaxTime} @@ -442,7 +436,7 @@ sub _ProcessingRetrieveData($$) { + 0.5 ), 'windGustTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i]->{windGustTime} ) @@ -450,13 +444,13 @@ sub _ProcessingRetrieveData($$) { 'moonPhase' => $data->{daily}->{data}->[$i]->{moonPhase}, 'sunsetTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i]->{sunsetTime} ) ), 'sunriseTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{daily}->{data}->[$i]->{sunriseTime} ) @@ -498,7 +492,7 @@ sub _ErrorHandling($$) { my ( $self, $err ) = @_; $self->{cached}->{current_date_time} = - strftime( "%a,%e %b %Y %H:%M %p", localtime( $self->{fetchTime} ) ), + strftime( "%a, %e %b %Y %H:%M %p", localtime( $self->{fetchTime} ) ), $self->{cached}->{status} = $err; $self->{cached}->{validity} = 'stale'; } diff --git a/OpenWeatherMapAPI.pm b/OpenWeatherMapAPI.pm index 446bc06..b3610d8 100644 --- a/OpenWeatherMapAPI.pm +++ b/OpenWeatherMapAPI.pm @@ -260,7 +260,7 @@ sub _ProcessingRetrieveData($$) { ###### Ab hier wird die ResponseHash Referenze für die Rückgabe zusammen gestellt $self->{cached}->{current_date_time} = - strftime( "%a,%e %b %Y %H:%M %p", + strftime( "%a, %e %b %Y %H:%M %p", localtime( $self->{fetchTime} ) ); if ( $self->{endpoint} eq 'weather' ) { @@ -308,15 +308,15 @@ sub _ProcessingRetrieveData($$) { 'code' => $codes{ $data->{weather}->[0]->{id} }, 'iconAPI' => $data->{weather}->[0]->{icon}, 'sunsetTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{sys}->{sunset} ) ), 'sunriseTime' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{sys}->{sunrise} ) ), 'pubDate' => strftime( - "%a,%e %b %Y %H:%M %p", + "%a, %e %b %Y %H:%M %p", localtime( $data->{dt} ) ), }; @@ -334,6 +334,12 @@ sub _ProcessingRetrieveData($$) { push( @{ $self->{cached}->{forecast}->{hourly} }, { + 'pubDate' => strftime( + "%a, %e %b %Y %H:%M %p", + localtime( + ( $data->{list}->[$i]->{dt} ) - 3600 + ) + ), 'temperature' => int( sprintf( "%.1f", @@ -416,12 +422,6 @@ sub _ProcessingRetrieveData($$) { ->{id} }, 'iconAPI' => $data->{list}->[$i]->{weather}->[0]->{icon}, - 'pubDate' => strftime( - "%a,%e %b %Y %H:%M %p", - localtime( - ( $data->{list}->[$i]->{dt} ) - 3600 - ) - ), }, ); @@ -452,7 +452,7 @@ sub _ErrorHandling($$) { my ( $self, $err ) = @_; $self->{cached}->{current_date_time} = - strftime( "%a,%e %b %Y %H:%M %p", localtime( $self->{fetchTime} ) ), + strftime( "%a, %e %b %Y %H:%M %p", localtime( $self->{fetchTime} ) ), $self->{cached}->{status} = $err; $self->{cached}->{validity} = 'stale'; }