Skip to content

Commit

Permalink
fix issues with local time
Browse files Browse the repository at this point in the history
  • Loading branch information
seandepagnier committed Jun 2, 2018
1 parent 21aec1b commit 8ef61d6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET(PLUGIN_VERSION_MAJOR "1")
SET(PLUGIN_VERSION_MINOR "12")
SET(PLUGIN_VERSION_PATCH "0")
SET(PLUGIN_VERSION_DATE "2018-03-25")
SET(PLUGIN_VERSION_PATCH "1")
SET(PLUGIN_VERSION_DATE "2018-06-02")
64 changes: 32 additions & 32 deletions src/ConfigurationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,44 +347,44 @@ void ConfigurationDialog::Update()
GET_CHOICE(End);

if(std::find(m_edited_controls.begin(), m_edited_controls.end(), (wxObject*)m_dpStartDate) != m_edited_controls.end()) {
if(m_dpStartDate->GetValue().IsValid()) {
int h, m, s;
bool reset = false;

if(std::find(m_edited_controls.begin(), m_edited_controls.end(), (wxObject*)m_tpTime) == m_edited_controls.end()) {
// We must preserve the time in case only date but not time, is being changed by the user...
// configuration.StartTime is UTC, m_dpStartDate Local or UTC so adjust
wxDateTime datetime = configuration.StartTime;

reset = true;
if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue())
datetime = datetime.FromUTC();

h = datetime.GetHour();
m = datetime.GetMinute();
s = datetime.GetSecond();
}
configuration.StartTime = m_dpStartDate->GetValue();
m_dpStartDate->SetForegroundColour(wxColour(0, 0, 0));
if(reset) {
// ... and add it afterwards
configuration.StartTime.SetHour(h);
configuration.StartTime.SetMinute(m);
configuration.StartTime.SetSecond(s);
}
}
if(!m_dpStartDate->GetValue().IsValid())
continue;
// We must preserve the time in case only date but not time, is being changed by the user...
// configuration.StartTime is UTC, m_dpStartDate Local or UTC so adjust
wxDateTime time = configuration.StartTime;
if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue())
time = time.FromUTC();

wxDateTime date = m_dpStartDate->GetValue();
// ... and add it afterwards
date.SetHour(time.GetHour());
date.SetMinute(time.GetMinute());
date.SetSecond(time.GetSecond());

if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue())
date = date.ToUTC();

configuration.StartTime = date;
m_dpStartDate->SetForegroundColour(wxColour(0, 0, 0));
}

if(std::find(m_edited_controls.begin(), m_edited_controls.end(), (wxObject*)m_tpTime) != m_edited_controls.end()) {
configuration.StartTime.SetHour(m_tpTime->GetValue().GetHour());
configuration.StartTime.SetMinute(m_tpTime->GetValue().GetMinute());
configuration.StartTime.SetSecond(m_tpTime->GetValue().GetSecond());
// must use correct data on UTC conversion to preserve Daylight Savings Time changes across dates
wxDateTime time = configuration.StartTime;
if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue())
time = time.FromUTC();

time.SetHour(m_tpTime->GetValue().GetHour());
time.SetMinute(m_tpTime->GetValue().GetMinute());
time.SetSecond(m_tpTime->GetValue().GetSecond());

if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue())
time = time.ToUTC();

configuration.StartTime = time;
m_tpTime->SetForegroundColour(wxColour(0, 0, 0));
}

if(m_WeatherRouting.m_SettingsDialog.m_cbUseLocalTime->GetValue())
configuration.StartTime = configuration.StartTime.ToUTC();

if(!m_tBoat->GetValue().empty()) {
configuration.boatFileName = m_tBoat->GetValue();
m_tBoat->SetForegroundColour(wxColour(0, 0, 0));
Expand Down

0 comments on commit 8ef61d6

Please sign in to comment.