Simple Weather Service : Fix timestamp

In the documentation, specify that the timestamp is expressed in seconds from epoch (instead of nanoseconds).
SimpleWeatherService now uses "localtime" (GetCurrentDateTime()) instead of UTC time.
This commit is contained in:
Jean-François Milants
2024-01-02 12:27:16 +01:00
committed by JF
parent 9b36afc787
commit b4ff1f9ca2
2 changed files with 4 additions and 4 deletions

View File

@@ -127,7 +127,7 @@ int SimpleWeatherService::OnCommand(struct ble_gatt_access_ctxt* ctxt) {
std::optional<SimpleWeatherService::CurrentWeather> SimpleWeatherService::Current() const {
if (currentWeather) {
auto currentTime = dateTimeController.UTCDateTime().time_since_epoch();
auto currentTime = dateTimeController.CurrentDateTime().time_since_epoch();
auto weatherTpSecond = std::chrono::seconds {currentWeather->timestamp};
auto weatherTp = std::chrono::duration_cast<std::chrono::seconds>(weatherTpSecond);
auto delta = currentTime - weatherTp;
@@ -141,7 +141,7 @@ std::optional<SimpleWeatherService::CurrentWeather> SimpleWeatherService::Curren
std::optional<SimpleWeatherService::Forecast> SimpleWeatherService::GetForecast() const {
if (forecast) {
auto currentTime = dateTimeController.UTCDateTime().time_since_epoch();
auto currentTime = dateTimeController.CurrentDateTime().time_since_epoch();
auto weatherTpSecond = std::chrono::seconds {forecast->timestamp};
auto weatherTp = std::chrono::duration_cast<std::chrono::seconds>(weatherTpSecond);
auto delta = currentTime - weatherTp;