Skip to content

Commit

Permalink
Fixed rain1h and observation time in owm api 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
naofireblade committed Dec 29, 2022
1 parent b1f741c commit afd3609
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apis/openweathermap.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ class OpenWeatherMapAPI
if (this.api === "2.5")
{
this.parseReportLegacy(weather.report, values);
let timezoneShift = timezone / 60
weather.report.ObservationTime = moment.unix(values.dt).utcOffset(timezoneShift).format('HH:mm:ss');
}
else
{
this.parseReportOneCall(weather.report, values["current"]);
weather.report.ObservationTime = moment.unix(values["current"].dt).tz(timezone).format('HH:mm:ss');
}
let timezoneShift = timezone / 60
weather.report.ObservationTime = moment.unix(values.dt).utcOffset(timezoneShift).format('HH:mm:ss');

if (weather.forecasts)
{
Expand Down Expand Up @@ -301,6 +302,9 @@ class OpenWeatherMapAPI
}
else
{
let precip1h = values.rain === undefined || isNaN(parseFloat(values.rain['1h'])) ? 0 : parseFloat(values.rain['1h']);
precip1h += values.snow === undefined || isNaN(parseFloat(values.snow['1h'])) ? 0 : parseFloat(values.snow['1h']);
report.Rain1h = precip1h;
report.Temperature = typeof values.temp === 'object' ? parseFloat(values.temp.day) : parseFloat(values.temp);
}
}
Expand Down

0 comments on commit afd3609

Please sign in to comment.