mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-11 00:29:11 +01:00
Fix issues with Custom RTC when set past the year 2038
This commit is contained in:
parent
40f4308dc2
commit
a3eb9082fc
@ -137,6 +137,11 @@ void AdvancedConfigPane::OnClockOverrideSliderChanged(wxCommandEvent& event)
|
|||||||
UpdateCPUClock();
|
UpdateCPUClock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 ToSeconds(wxDateTime date)
|
||||||
|
{
|
||||||
|
return static_cast<u32>(date.GetValue().GetValue() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
void AdvancedConfigPane::OnCustomRTCCheckBoxChanged(wxCommandEvent& event)
|
void AdvancedConfigPane::OnCustomRTCCheckBoxChanged(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
const bool checked = m_custom_rtc_checkbox->IsChecked();
|
const bool checked = m_custom_rtc_checkbox->IsChecked();
|
||||||
@ -147,13 +152,13 @@ void AdvancedConfigPane::OnCustomRTCCheckBoxChanged(wxCommandEvent& event)
|
|||||||
|
|
||||||
void AdvancedConfigPane::OnCustomRTCDateChanged(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);
|
UpdateCustomRTC(m_temp_date, m_temp_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdvancedConfigPane::OnCustomRTCTimeChanged(wxCommandEvent& event)
|
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);
|
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_date_picker->SetValue(custom_rtc);
|
||||||
m_custom_rtc_time_picker->SetValue(custom_rtc);
|
m_custom_rtc_time_picker->SetValue(custom_rtc);
|
||||||
}
|
}
|
||||||
m_temp_date = m_custom_rtc_date_picker->GetValue().GetTicks();
|
m_temp_date = ToSeconds(m_custom_rtc_date_picker->GetValue());
|
||||||
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;
|
||||||
// Limit dates to valid ranges (2000 to 2099 for GC, 2000 to 2035 for Wii)
|
// Limit dates to a valid range (Jan 1/2000 to Dec 31/2099)
|
||||||
if (SConfig::GetInstance().bWii)
|
m_custom_rtc_date_picker->SetRange(wxDateTime(1, wxDateTime::Jan, 2000),
|
||||||
m_custom_rtc_date_picker->SetRange(wxDateTime(1, wxDateTime::Jan, 2000),
|
wxDateTime(31, wxDateTime::Dec, 2099));
|
||||||
wxDateTime(31, wxDateTime::Dec, 2035));
|
|
||||||
else
|
|
||||||
m_custom_rtc_date_picker->SetRange(wxDateTime(1, wxDateTime::Jan, 2000),
|
|
||||||
wxDateTime(31, wxDateTime::Dec, 2099));
|
|
||||||
if (Core::IsRunning())
|
if (Core::IsRunning())
|
||||||
{
|
{
|
||||||
m_custom_rtc_checkbox->Enable(false);
|
m_custom_rtc_checkbox->Enable(false);
|
||||||
@ -203,7 +204,7 @@ void AdvancedConfigPane::LoadCustomRTC()
|
|||||||
void AdvancedConfigPane::UpdateCustomRTC(time_t date, time_t time)
|
void AdvancedConfigPane::UpdateCustomRTC(time_t date, time_t time)
|
||||||
{
|
{
|
||||||
wxDateTime custom_rtc(date + 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_date_picker->SetValue(custom_rtc);
|
||||||
m_custom_rtc_time_picker->SetValue(custom_rtc);
|
m_custom_rtc_time_picker->SetValue(custom_rtc);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user