bool DateTime::is_same_minute(const DateTime& a, const DateTime& b)
{
    if (!is_same_day(a,b))
        return false;

    const auto adt = a.get();
    const auto bdt = b.get();
    return (g_date_time_get_hour(adt) == g_date_time_get_hour(bdt))
        && (g_date_time_get_minute(adt) == g_date_time_get_minute(bdt));
}
Beispiel #2
0
bool Timer::trigger_time(uint64_t old_time, int hour, int minute)
{
	ACE_Time_Value old_tv;
	old_tv.set_msec(old_time);
	ACE_Date_Time old_dt(old_tv);
	uint64_t new_time = now();
	ACE_Time_Value new_tv;
	new_tv.set_msec(new_time);
	ACE_Date_Time new_dt(new_tv);
	
	if (new_time <= old_time)
	{
		return false;
	}

	if (new_time - old_time >= 86400000)
	{
		return true;
	}

	bool old_small = is_small(old_dt, hour, minute);
	bool new_small = is_small(new_dt, hour, minute);

	if (is_same_day(old_dt, new_dt))
	{
		if (old_small && !new_small)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		if (!old_small && !new_small)
		{
			return true;
		}
		else if (old_small && new_small)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	return false;
}