wxString pgsTimeGen::random() { wxTimeSpan time_span(0, 0, m_randomizer->random_long(), 0); wxDateTime aux_min(m_min); aux_min.Add(time_span); wxASSERT(aux_min.IsLaterThan(m_min) || aux_min.IsEqualTo(m_min)); wxASSERT(aux_min.IsEarlierThan(m_max) || aux_min.IsEqualTo(m_max)); return aux_min.FormatISOTime(); }
wxString pgsDateTimeGen::random() { // Get a random number representing seconds MAPM result = pgsMapm::pgs_str_mapm(m_randomizer->random()), quot, rem; // Use hours and seconds for avoiding overflows of seconds result.integer_div_rem(3600, quot, rem); long hours, seconds; pgsMapm::pgs_mapm_str(quot, true).ToLong(&hours); pgsMapm::pgs_mapm_str(rem, true).ToLong(&seconds); wxTimeSpan time_span(hours, 0, seconds, 0); // Add the TimeSpan to the MinDate wxDateTime aux_min(m_min); aux_min.Add(time_span); // Post conditions wxASSERT(aux_min.IsLaterThan(m_min) || aux_min.IsEqualTo(m_min)); wxASSERT(aux_min.IsEarlierThan(m_max) || aux_min.IsEqualTo(m_max)); return aux_min.Format(wxT("%Y-%m-%d %H:%M:%S")); }