From 75a3b8d53fb6d87e92bf9a3fb3afa6159c20d262 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sun, 14 Jan 2018 19:22:02 +0100 Subject: [PATCH] [weather] Add optional "Observation Timestamp" to dataengine data --- dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp | 3 +++ dataengines/weather/ions/envcan/ion_envcan.cpp | 5 +++++ dataengines/weather/ions/ion.h | 3 ++- dataengines/weather/ions/noaa/ion_noaa.cpp | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp b/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp index 40557b845..6acaa9bb3 100644 --- a/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp +++ b/dataengines/weather/ions/bbcukmet/ion_bbcukmet.cpp @@ -903,6 +903,9 @@ void UKMETIon::updateWeather(const QString& source) data.insert(QStringLiteral("Place"), weatherData.stationName); data.insert(QStringLiteral("Station"), weatherData.stationName); + if (weatherData.observationDateTime.isValid()) { + data.insert(QStringLiteral("Observation Timestamp"), weatherData.observationDateTime); + } if (!weatherData.obsTime.isEmpty()) { data.insert(QStringLiteral("Observation Period"), weatherData.obsTime); } diff --git a/dataengines/weather/ions/envcan/ion_envcan.cpp b/dataengines/weather/ions/envcan/ion_envcan.cpp index b849a4543..ce4772f1f 100644 --- a/dataengines/weather/ions/envcan/ion_envcan.cpp +++ b/dataengines/weather/ions/envcan/ion_envcan.cpp @@ -1436,7 +1436,12 @@ void EnvCanadaIon::updateWeather(const QString& source) } // Real weather - Current conditions + if (weatherData.observationDateTime.isValid()) { + data.insert(QStringLiteral("Observation Timestamp"), weatherData.observationDateTime); + } + data.insert(QStringLiteral("Observation Period"), weatherData.obsTimestamp); + if (!weatherData.condition.isEmpty()) { data.insert(QStringLiteral("Current Conditions"), i18nc("weather condition", weatherData.condition.toUtf8().data())); } diff --git a/dataengines/weather/ions/ion.h b/dataengines/weather/ions/ion.h index d22f78a3d..4b31f2a01 100644 --- a/dataengines/weather/ions/ion.h +++ b/dataengines/weather/ions/ion.h @@ -44,7 +44,8 @@ * "Longitude": float, longitude of the weather station in decimal degrees, optional * * Data about last observation: -* "Observation Period": string, free text string for time of observation, optional, TODO: get standardized datetime +* "Observation Period": string, free text string for time of observation, optional +* "Observation Timestamp": datetime (with timezone), time of observation, optional * "Current Conditions": string, free text string for current weather observation, optional * "Condition Icon": string, xdg icon name for current weather observation, optional * "Temperature": float, using general temperature unit, optional diff --git a/dataengines/weather/ions/noaa/ion_noaa.cpp b/dataengines/weather/ions/noaa/ion_noaa.cpp index 40a5b02cd..cebba5af2 100644 --- a/dataengines/weather/ions/noaa/ion_noaa.cpp +++ b/dataengines/weather/ions/noaa/ion_noaa.cpp @@ -564,7 +564,12 @@ void NOAAIon::updateWeather(const QString& source) } // Real weather - Current conditions + if (weatherData.observationDateTime.isValid()) { + data.insert(QStringLiteral("Observation Timestamp"), weatherData.observationDateTime); + } + data.insert(QStringLiteral("Observation Period"), weatherData.observationTime); + const QString conditionI18n = weatherData.weather == QLatin1String("N/A") ? i18n("N/A") : i18nc("weather condition", weatherData.weather.toUtf8().data()); data.insert(QStringLiteral("Current Conditions"), conditionI18n);