+
+ // Set the given time.
+ bool SetTime(int hour, int min, int sec)
+ {
+ // Notice that we should use a date on which DST doesn't change to
+ // avoid any problems with time discontinuity so use a fixed date (on
+ // which nobody changes DST) instead of e.g. today.
+ wxDateTime dt(1, wxDateTime::Jan, 2012, hour, min, sec);
+ if ( !dt.IsValid() )
+ {
+ // No need to assert here, wxDateTime already does it for us.
+ return false;
+ }
+
+ SetValue(dt);
+
+ return true;
+ }
+
+ // Get the current time components. All pointers must be non-NULL.
+ bool GetTime(int* hour, int* min, int* sec) const
+ {
+ wxCHECK_MSG( hour && min && sec, false,
+ wxS("Time component pointers must be non-NULL") );
+
+ const wxDateTime::Tm tm = GetValue().GetTm();
+ *hour = tm.hour;
+ *min = tm.min;
+ *sec = tm.sec;
+
+ return true;
+ }