diff options
| author | Chris Burgener <christhecoolist@gmail.com> | 2016-08-19 17:16:28 -0400 |
|---|---|---|
| committer | Chris Burgener <christhecoolist@gmail.com> | 2016-08-21 13:33:01 -0400 |
| commit | a3eb9082fce0d5bae20b89ea943fa0a8d57c77fe (patch) | |
| tree | 438ae4a93efe09a8f467991e39bcb5bf7c2df8f1 | |
| parent | 40f4308dc2120ce4e105008f3cb46b6a1c553e64 (diff) | |
Fix issues with Custom RTC when set past the year 2038
| -rw-r--r-- | Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp b/Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp index b24f81036a..4f9934fc39 100644 --- a/Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/AdvancedConfigPane.cpp @@ -137,6 +137,11 @@ void AdvancedConfigPane::OnClockOverrideSliderChanged(wxCommandEvent& event) UpdateCPUClock(); } +u32 ToSeconds(wxDateTime date) +{ + return static_cast<u32>(date.GetValue().GetValue() / 1000); +} + void AdvancedConfigPane::OnCustomRTCCheckBoxChanged(wxCommandEvent& event) { const bool checked = m_custom_rtc_checkbox->IsChecked(); @@ -147,13 +152,13 @@ void AdvancedConfigPane::OnCustomRTCCheckBoxChanged(wxCommandEvent& event) void AdvancedConfigPane::OnCustomRTCDateChanged(wxCommandEvent& event) { - m_temp_date = m_custom_rtc_date_picker->GetValue().GetTicks(); + m_temp_date = ToSeconds(m_custom_rtc_date_picker->GetValue()); UpdateCustomRTC(m_temp_date, m_temp_time); } void AdvancedConfigPane::OnCustomRTCTimeChanged(wxCommandEvent& event) { - m_temp_time = m_custom_rtc_time_picker->GetValue().GetTicks() - m_temp_date; + m_temp_time = ToSeconds(m_custom_rtc_time_picker->GetValue()) - m_temp_date; UpdateCustomRTC(m_temp_date, m_temp_time); } @@ -178,15 +183,11 @@ void AdvancedConfigPane::LoadCustomRTC() m_custom_rtc_date_picker->SetValue(custom_rtc); m_custom_rtc_time_picker->SetValue(custom_rtc); } - m_temp_date = m_custom_rtc_date_picker->GetValue().GetTicks(); - m_temp_time = m_custom_rtc_time_picker->GetValue().GetTicks() - m_temp_date; - // Limit dates to valid ranges (2000 to 2099 for GC, 2000 to 2035 for Wii) - if (SConfig::GetInstance().bWii) - m_custom_rtc_date_picker->SetRange(wxDateTime(1, wxDateTime::Jan, 2000), - wxDateTime(31, wxDateTime::Dec, 2035)); - else - m_custom_rtc_date_picker->SetRange(wxDateTime(1, wxDateTime::Jan, 2000), - wxDateTime(31, wxDateTime::Dec, 2099)); + m_temp_date = ToSeconds(m_custom_rtc_date_picker->GetValue()); + m_temp_time = ToSeconds(m_custom_rtc_time_picker->GetValue()) - m_temp_date; + // Limit dates to a valid range (Jan 1/2000 to Dec 31/2099) + m_custom_rtc_date_picker->SetRange(wxDateTime(1, wxDateTime::Jan, 2000), + wxDateTime(31, wxDateTime::Dec, 2099)); if (Core::IsRunning()) { m_custom_rtc_checkbox->Enable(false); @@ -203,7 +204,7 @@ void AdvancedConfigPane::LoadCustomRTC() void AdvancedConfigPane::UpdateCustomRTC(time_t date, time_t time) { wxDateTime custom_rtc(date + time); - SConfig::GetInstance().m_customRTCValue = custom_rtc.FromUTC().GetTicks(); + SConfig::GetInstance().m_customRTCValue = ToSeconds(custom_rtc.FromUTC()); m_custom_rtc_date_picker->SetValue(custom_rtc); m_custom_rtc_time_picker->SetValue(custom_rtc); } |
