WeatherService daily min/max temperature fixes (#1455)
* Min/Max function fixes * Faster way to calculate day start
This commit is contained in:
parent
7376c02bbf
commit
f1d2a8ee50
|
@ -552,11 +552,12 @@ namespace Pinetime {
|
||||||
|
|
||||||
int16_t WeatherService::GetTodayMinTemp() const {
|
int16_t WeatherService::GetTodayMinTemp() const {
|
||||||
uint64_t currentTimestamp = GetCurrentUnixTimestamp();
|
uint64_t currentTimestamp = GetCurrentUnixTimestamp();
|
||||||
uint64_t currentDayEnd = currentTimestamp - ((24 - dateTimeController.Hours()) * 60 * 60) -
|
uint64_t currentDayEnd = currentTimestamp + ((24 - dateTimeController.Hours()) * 60 * 60) +
|
||||||
((60 - dateTimeController.Minutes()) * 60) - (60 - dateTimeController.Seconds());
|
((60 - dateTimeController.Minutes()) * 60) + (60 - dateTimeController.Seconds());
|
||||||
|
uint64_t currentDayStart = currentDayEnd - 86400;
|
||||||
int16_t result = -32768;
|
int16_t result = -32768;
|
||||||
for (auto&& header : this->timeline) {
|
for (auto&& header : this->timeline) {
|
||||||
if (header->eventType == WeatherData::eventtype::Temperature && IsEventStillValid(header, currentTimestamp) &&
|
if (header->eventType == WeatherData::eventtype::Temperature && header->timestamp >= currentDayStart &&
|
||||||
header->timestamp < currentDayEnd &&
|
header->timestamp < currentDayEnd &&
|
||||||
reinterpret_cast<const std::unique_ptr<WeatherData::Temperature>&>(header)->temperature != -32768) {
|
reinterpret_cast<const std::unique_ptr<WeatherData::Temperature>&>(header)->temperature != -32768) {
|
||||||
int16_t temperature = reinterpret_cast<const std::unique_ptr<WeatherData::Temperature>&>(header)->temperature;
|
int16_t temperature = reinterpret_cast<const std::unique_ptr<WeatherData::Temperature>&>(header)->temperature;
|
||||||
|
@ -575,11 +576,12 @@ namespace Pinetime {
|
||||||
|
|
||||||
int16_t WeatherService::GetTodayMaxTemp() const {
|
int16_t WeatherService::GetTodayMaxTemp() const {
|
||||||
uint64_t currentTimestamp = GetCurrentUnixTimestamp();
|
uint64_t currentTimestamp = GetCurrentUnixTimestamp();
|
||||||
uint64_t currentDayEnd = currentTimestamp - ((24 - dateTimeController.Hours()) * 60 * 60) -
|
uint64_t currentDayEnd = currentTimestamp + ((24 - dateTimeController.Hours()) * 60 * 60) +
|
||||||
((60 - dateTimeController.Minutes()) * 60) - (60 - dateTimeController.Seconds());
|
((60 - dateTimeController.Minutes()) * 60) + (60 - dateTimeController.Seconds());
|
||||||
|
uint64_t currentDayStart = currentDayEnd - 86400;
|
||||||
int16_t result = -32768;
|
int16_t result = -32768;
|
||||||
for (auto&& header : this->timeline) {
|
for (auto&& header : this->timeline) {
|
||||||
if (header->eventType == WeatherData::eventtype::Temperature && IsEventStillValid(header, currentTimestamp) &&
|
if (header->eventType == WeatherData::eventtype::Temperature && header->timestamp >= currentDayStart &&
|
||||||
header->timestamp < currentDayEnd &&
|
header->timestamp < currentDayEnd &&
|
||||||
reinterpret_cast<const std::unique_ptr<WeatherData::Temperature>&>(header)->temperature != -32768) {
|
reinterpret_cast<const std::unique_ptr<WeatherData::Temperature>&>(header)->temperature != -32768) {
|
||||||
int16_t temperature = reinterpret_cast<const std::unique_ptr<WeatherData::Temperature>&>(header)->temperature;
|
int16_t temperature = reinterpret_cast<const std::unique_ptr<WeatherData::Temperature>&>(header)->temperature;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user