diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b8831d..7aac624 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log +## 1.7.2 + +- 🎁 Keeping time intact while importing from `main.mcf` or METAR info + + ## 1.7.1 - 💊 Fixed time zone issues diff --git a/src/WettergeraetDesktop/Frame.cpp b/src/WettergeraetDesktop/Frame.cpp index 17fe3e7..612bd7d 100644 --- a/src/WettergeraetDesktop/Frame.cpp +++ b/src/WettergeraetDesktop/Frame.cpp @@ -286,20 +286,22 @@ void Frame::fromObjectToInput() { this->icaoInput->SetValue(wxString(this->aerofly.nearestAirport)); - /* - Keep date / time at current date / time to enable fetching of current weather + // Discard date from Aerofly date, instead set it to today... + this->utcDateValue = wxDateTime::Now().MakeUTC(); - this->utcDateValue.SetYear(this->aerofly.year); - this->utcDateValue.SetMonth((wxDateTime::Month)(this->aerofly.month - 1)); - this->utcDateValue.SetDay(this->aerofly.day); + // ...but keep the time auto hour = floor(this->aerofly.hours); this->utcDateValue.SetHour(hour); this->utcDateValue.SetMinute(round((this->aerofly.hours - hour) * 60)); this->utcDateValue.SetSecond(0); + if (this->utcDateValue.IsLaterThan(wxDateTime::Now().MakeUTC())) { + // Substract one day if current datetime is in future + this->utcDateValue = this->utcDateValue.Subtract(wxDateSpan::Day()); + } + this->utcTimeInput->SetValue(this->utcDateValue); this->utcDateInput->SetValue(this->utcDateValue); - */ this->windDirectionInput->SetValue(this->aerofly.windDirection); this->windStrengthInput->SetValue(ceil(this->aerofly.getWindKts())); diff --git a/src/WettergeraetLib/AeroflyWeather.cpp b/src/WettergeraetLib/AeroflyWeather.cpp index b5e41cc..7bb7dbd 100644 --- a/src/WettergeraetLib/AeroflyWeather.cpp +++ b/src/WettergeraetLib/AeroflyWeather.cpp @@ -175,8 +175,8 @@ double AeroflyWeather::getPressureHpa() void AeroflyWeather::setFromMetar(const MetarParserSimple& metar) { this->setNearestAirport(metar.icao); - this->setDate(metar.observed.year, metar.observed.month, metar.observed.day); - this->setTime(metar.observed.hours, metar.observed.minutes); + //this->setDate(metar.observed.year, metar.observed.month, metar.observed.day); + //this->setTime(metar.observed.hours, metar.observed.minutes); this->setWind(metar.wind.speedKts, metar.wind.degrees); this->setTurbulence(metar.wind.speedKts, metar.wind.gustKts, metar.wind.degreesFrom, metar.wind.degreesTo, metar.conditions); this->setThermalActivity(metar.temperatureCelsius);