Added wxTimePickerCtrl::GetTime() and SetTime().
These methods, taking broken down time representation, avoid the problems arising due to DST complications when using wxDateTime to represent the time as special care needs to be taken in this case to avoid using the date part corresponding to a DST change date at which time is discontinuous. Document the problem with the old functions and use the new ones in the sample. See #14137. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71004 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
25d7cf54f0
commit
c0795ce8ea
4 changed files with 82 additions and 8 deletions
|
|
@ -217,21 +217,23 @@ void TimePickerWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
|
|||
|
||||
void TimePickerWidgetsPage::OnButtonSet(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDateTime dt;
|
||||
if ( !dt.ParseISOTime(m_textCur->GetValue()) )
|
||||
int h, m, s;
|
||||
if ( wxSscanf(m_textCur->GetValue(), "%d:%d:%d", &h, &m, &s) != 3 )
|
||||
{
|
||||
wxLogError("Invalid time, please use HH:MM:SS format.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_timePicker->SetValue(dt);
|
||||
m_timePicker->SetTime(h, m, s);
|
||||
}
|
||||
|
||||
void TimePickerWidgetsPage::OnTimeChanged(wxDateEvent& event)
|
||||
{
|
||||
wxLogMessage("Time changed, now is %s (control value is %s).",
|
||||
event.GetDate().FormatISOTime(),
|
||||
m_timePicker->GetValue().FormatISOTime());
|
||||
int h, m, s;
|
||||
m_timePicker->GetTime(&h, &m, &s);
|
||||
|
||||
wxLogMessage("Time changed, now is %s (control value is %02d:%02d:%02d).",
|
||||
event.GetDate().FormatISOTime(), h, m, s);
|
||||
}
|
||||
|
||||
#endif // wxUSE_TIMEPICKCTRL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue