Implemented beginOfMonth() and endOfMonth()

This commit is contained in:
Daniel Brunner
2018-11-16 23:14:28 +01:00
parent 312759af4c
commit e31dffb94f
2 changed files with 15 additions and 0 deletions

View File

@@ -21,3 +21,15 @@ QTime timeNormalise(const QTime &time)
{
return QTime(time.hour(), time.minute());
}
QDate beginOfMonth(QDate date)
{
bool success = date.setDate(date.year(), date.month(), 1);
Q_ASSERT(success);
return date;
}
QDate endOfMonth(const QDate &date)
{
return beginOfMonth(date.addMonths(1)).addDays(-1);
}

View File

@@ -8,3 +8,6 @@ int DBCORELIB_EXPORT timeToSeconds(const QTime &time);
QTime DBCORELIB_EXPORT timeBetween(const QTime &l, const QTime &r);
QTime DBCORELIB_EXPORT timeAdd(const QTime &l, const QTime &r);
QTime DBCORELIB_EXPORT timeNormalise(const QTime &time);
QDate DBCORELIB_EXPORT beginOfMonth(QDate date);
QDate DBCORELIB_EXPORT endOfMonth(const QDate &date);