change day_of_week language handling

This commit is contained in:
Marko Oldenburg
2019-01-11 08:47:13 +01:00
parent b9bb92d6f4
commit 76a995a95d
3 changed files with 32 additions and 38 deletions

View File

@ -138,7 +138,7 @@ sub Weather_Initialize($) {
$hash->{UndefFn} = "Weather_Undef"; $hash->{UndefFn} = "Weather_Undef";
$hash->{GetFn} = "Weather_Get"; $hash->{GetFn} = "Weather_Get";
$hash->{SetFn} = "Weather_Set"; $hash->{SetFn} = "Weather_Set";
$hash->{AttrList}= "disable " . $readingFnAttributes; $hash->{AttrList}= "disable:0,1 " . $readingFnAttributes;
$hash->{NotifyFn}= "Weather_Notify"; $hash->{NotifyFn}= "Weather_Notify";
#Weather_DebugCodes('de'); #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); 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 . '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); 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 . '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) ) );
} }
} }
} }

View File

@ -267,14 +267,8 @@ sub _ProcessingRetrieveData($$) {
push( push(
@{ $self->{cached}->{forecast}->{daily} }, @{ $self->{cached}->{forecast}->{daily} },
{ {
'date' => strftime( 'pubDate' => strftime(
"%a, %d.%m.%Y", "%a, %e %b %Y %H:%M %p",
localtime(
$data->{daily}->{data}->[$i]->{'time'}
)
),
'day_of_week' => strftime(
"%a",
localtime( localtime(
$data->{daily}->{data}->[$i]->{'time'} $data->{daily}->{data}->[$i]->{'time'}
) )

View File

@ -334,6 +334,12 @@ sub _ProcessingRetrieveData($$) {
push( push(
@{ $self->{cached}->{forecast}->{hourly} }, @{ $self->{cached}->{forecast}->{hourly} },
{ {
'pubDate' => strftime(
"%a, %e %b %Y %H:%M %p",
localtime(
( $data->{list}->[$i]->{dt} ) - 3600
)
),
'temperature' => int( 'temperature' => int(
sprintf( sprintf(
"%.1f", "%.1f",
@ -416,12 +422,6 @@ sub _ProcessingRetrieveData($$) {
->{id} }, ->{id} },
'iconAPI' => 'iconAPI' =>
$data->{list}->[$i]->{weather}->[0]->{icon}, $data->{list}->[$i]->{weather}->[0]->{icon},
'pubDate' => strftime(
"%a,%e %b %Y %H:%M %p",
localtime(
( $data->{list}->[$i]->{dt} ) - 3600
)
),
}, },
); );