Add QCronHolidayNode.

This commit is contained in:
vincent 2016-01-04 14:54:43 +01:00
parent f047138eaf
commit edf728d80a
4 changed files with 90 additions and 11 deletions

@ -131,6 +131,18 @@ _parseNode(QString & str)
{
node = _parseList(str);
}
else if (_field == DOM)
{
if ('F' == c)
{
str.remove(0, 1);
node = new QCronHolidayNode();
}
else if ('f' == c)
{
}
}
if (NULL == node)
{
throw QCronFieldException(QString("Unexpected character %1").arg(c));

@ -1,8 +1,7 @@
#include "qcronnode.hpp"
#include "qcronfield.hpp"
#include "qcron.hpp"
#include <QDebug>
#include "holiday.hpp"
#include <QDebug>
@ -328,3 +327,42 @@ match(int tu) const
/******************************************************************************/
/******************************************************************************/
int
QCronHolidayNode::
next(int t) const
{
Q_UNUSED(t)
//return Holiday::next(t);
return -1;
}
/******************************************************************************/
void
QCronHolidayNode::
process(QCron * cron,
QDateTime & dt,
EField field)
{
Q_UNUSED(cron);
if (DOM == field)
{
QDate next_holiday = Holiday::next(dt.date());
dt.setDate(next_holiday);
}
qFatal("Should not be there.");
}
/******************************************************************************/
bool
QCronHolidayNode::
match(int tu) const
{
Q_UNUSED(tu);
return false;
}
/******************************************************************************/
/******************************************************************************/

@ -27,10 +27,14 @@ protected:
QCronField * _field;
};
/******************************************************************************/
class QCronValueNode : public QCronNode
{
};
/******************************************************************************/
class QCronIntNode : public QCronValueNode
{
public:
@ -49,6 +53,8 @@ private:
int _value;
};
/******************************************************************************/
class QCronStrNode : public QCronValueNode
{
public:
@ -59,6 +65,8 @@ public:
EField field) Q_DECL_OVERRIDE;
};
/******************************************************************************/
class QCronAllNode : public QCronValueNode
{
public:
@ -69,6 +77,8 @@ public:
EField field) Q_DECL_OVERRIDE;
};
/******************************************************************************/
class QCronRangeNode : public QCronNode
{
public:
@ -90,6 +100,8 @@ private:
const QCronIntNode * _end;
};
/******************************************************************************/
class QCronEveryNode : public QCronNode
{
public:
@ -107,6 +119,8 @@ private:
QCronIntNode * _freq;
};
/******************************************************************************/
class QCronListNode : public QCronNode
{
public:
@ -122,4 +136,19 @@ private:
QList<QCronNode*> _nodes;
};
/******************************************************************************/
class QCronHolidayNode : public QCronNode
{
public:
virtual int next(int t) const;
virtual bool match(int tu) const;
virtual void process(QCron * cron,
QDateTime & dt,
EField field);
};
/******************************************************************************/
#endif

@ -28,6 +28,15 @@ actual(QString & pattern)
/******************************************************************************/
QDateTime
QCronTest::
now()
{
return QDateTime(_dnow, _tnow);
}
/******************************************************************************/
void
QCronTest::
minutes()
@ -143,15 +152,6 @@ minutes()
/******************************************************************************/
QDateTime
QCronTest::
now()
{
return QDateTime(_dnow, _tnow);
}
/******************************************************************************/
void
QCronTest::