summaryrefslogtreecommitdiff
path: root/src/objectvalidation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/objectvalidation.cpp')
-rw-r--r--src/objectvalidation.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/objectvalidation.cpp b/src/objectvalidation.cpp
index 04cd0b6..eeaa660 100644
--- a/src/objectvalidation.cpp
+++ b/src/objectvalidation.cpp
@@ -24,22 +24,36 @@
#include "kolabconfiguration.h"
#include "kolabfile.h"
#include "utils.h"
+#include "tztable.h"
+#include <boost/unordered_set.hpp>
namespace Kolab {
+static boost::unordered::unordered_set<std::string> initializeTzSet() {
+ boost::unordered::unordered_set<std::string> set;
+ for (int i = 0; i < numOlsonTimezones; i++) {
+ set.insert(olsonTimezones[i]);
+ }
+ return set;
+}
+
+const boost::unordered::unordered_set<std::string> tzSet = initializeTzSet();
+
bool isValid(const cDateTime &datetime)
{
if (!datetime.isValid()) {
return true;
}
const std::string tz = datetime.timezone();
- if (datetime.isUTC() && !tz.empty()) {
- Utils::logMessage("A UTC datetime may not have a timezone", "", 0, Error);
- return false;
- }
- if (tz == "Z") {
- Utils::logMessage("Z is not a valid timezone. Set to UTC instead", "", 0, Error);
- return false;
+ if (!tz.empty()) {
+ if (datetime.isUTC() && !tz.empty()) {
+ Utils::logMessage("A UTC datetime may not have a timezone", "", 0, Error);
+ return false;
+ }
+ if (tzSet.find(tz) == tzSet.end()) {
+ Utils::logMessage("not a valid olson timezone.", "", 0, Error);
+ return false;
+ }
}
return true;
}
@@ -91,7 +105,7 @@ void validate(const Todo& todo)
void validate(const Journal& journal)
{
-
+ ASSERTVALID(journal.start());
}
void validate(const Contact& contact)