summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vsession.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index f51fa3a..35292d2 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -2,6 +2,8 @@
#include <QDir>
#include <QApplication>
#include <QProcess>
+#include <QDate>
+#include <QStringList>
#if 0
#include <QHostInfo> // available since Qt 4.7
#endif
@@ -83,8 +85,39 @@ ImgType VSession::imgtype() const {
}
bool VSession::isActive() const {
- // default to true
- return getAttribute("active").compare("false");
+ QString value(getAttribute("active"));
+
+ if (value.compare("false")) {
+ return false;
+ } else if (value.count("/") == 1) {
+ // try to interpret value as date range
+ // [YYYY-MM-DD]/[YYYY-MM-DD]
+ // eg. "1970-01-01/1971-01-01" from Jan 1st 1970 till Jan 1st 1971
+ // "/1971-01-01" till Jan 1st 1971
+ // "1970-01-01/" from Jan 1st 1970
+ // "/" allways
+ // note: invalid dates are treated as empty dates
+
+ QStringList list(value.split("/"));
+ QString from(list.value(0));
+ QString till(list.value(1));
+ QDate fromDate(QDate::fromString(from, Qt::ISODate));
+ QDate tillDate(QDate::fromString(till, Qt::ISODate));
+
+ QDate today(QDate::currentDate());
+
+ if (fromDate.isValid() && fromDate > today) {
+ // fromDate is in the future
+ return false;
+ }
+
+ if (tillDate.isValid() && tillDate < today) {
+ // tillDate is in the past
+ return false;
+ }
+ }
+
+ return true;
}
bool VSession::isLocked() const {