QDateTime ts = QDateTime::currentDateTimeUtc();
QDateTime t1 = ts.addSecs(-5);
QDateTime t2 = ts.addSecs(5);
QVector<QDateTime> timeline;
int boo[] = {1,2,3,4,5,6};
foreach(int a, boo)
{
timeline.append(t1.addSecs(a));
}
bool found = false;
QDateTime prev = t1;
foreach(const QDateTime & curr, timeline)
{
qint64 dx = prev.msecsTo(ts);
qint64 dy = curr.msecsTo(ts);
if (dx < 0 && dy > 0)
{
yes = std::min(-dx, dy);
}
}