pgsDateTimeGen::pgsDateTimeGen(wxDateTime min, wxDateTime max,
		const bool & sequence, const long & seed) :
	pgsObjectGen(seed), m_min(min.IsEarlierThan(max) || min.IsEqualTo(max) ? min : max),
			m_max(max.IsLaterThan(min) || max.IsEqualTo(min) ? max : min),
			m_range(m_max.Subtract(m_min).GetSeconds()), m_sequence(sequence)
{
	m_randomizer = pgsRandomizer(pnew pgsIntegerGen(0, std::string(m_range
			.ToString().mb_str()).c_str(), is_sequence(), m_seed));
}
Exemple #2
0
pgsTimeGen::pgsTimeGen(wxDateTime min, wxDateTime max, const bool & sequence,
		const long & seed) :
	pgsObjectGen(seed), m_min(min.IsEarlierThan(max) || min.IsEqualTo(max) ? min : max),
			m_max(max.IsLaterThan(min) || max.IsEqualTo(min) ? max : min),
			m_range(m_max.Subtract(m_min).GetSeconds()), m_sequence(sequence)
{
	m_min.SetYear(1970); // We know this date is not a DST date
	m_min.SetMonth(wxDateTime::Jan);
	m_min.SetDay(1);
	m_randomizer = pgsRandomizer(pnew pgsIntegerGen(0, std::string(m_range
			.ToString().mb_str()).c_str(), is_sequence(), m_seed));
}
Exemple #3
0
int Timeline::AddItem(const wxDateTime& date) {
	item new_item;
	new_item.date = date;

	if (m_items.empty()) new_item.ypos = 0;
	else if (date.IsSameDate(m_items.back().date)) {
		new_item.ypos = m_items.back().ypos + m_itemHeight;
	}
	else if (date.IsEarlierThan(m_items.back().date)) {
		// Dates have to be sequential
		new_item.date = m_items.back().date; // force to same date as previous
		new_item.ypos = m_items.back().ypos + m_itemHeight;
	}
	else {
		// Calculate number of days between dates
		wxDateTime firstDay = m_items.back().date;
		wxDateTime secondDay = date;
		firstDay.ResetTime();
		secondDay.ResetTime();

		wxTimeSpan time = secondDay - firstDay;
		int days = time.GetDays();

		// BUG WORKAROUND: Because of shift to daylight saving time
		// the count of days might be one less.
		if (time.GetHours() % 24 == 23) ++days;

		wxASSERT(days > 0);

		new_item.ypos = m_items.back().ypos + (days * m_itemHeight);
	}

	m_items.push_back(new_item);

	return new_item.ypos;
}