Commit 844b643552e3b5cabeeafe1a04802dca5c3df018

Authored by Josh Klontz
1 parent 55756d38

added age calculation

Showing 1 changed file with 10 additions and 0 deletions
sdk/plugins/format.cpp
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 * limitations under the License. * 14 * limitations under the License. *
15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16
  17 +#include <QDate>
17 #ifndef BR_EMBEDDED 18 #ifndef BR_EMBEDDED
18 #include <QNetworkAccessManager> 19 #include <QNetworkAccessManager>
19 #include <QNetworkReply> 20 #include <QNetworkReply>
@@ -179,6 +180,15 @@ class xmlFormat : public Format @@ -179,6 +180,15 @@ class xmlFormat : public Format
179 subject = subject.nextSibling(); 180 subject = subject.nextSibling();
180 } 181 }
181 182
  183 + // Calculate age
  184 + if (t.file.contains("DOB")) {
  185 + const QDate dob = QDate::fromString(t.file.getString("DOB").left(10), "yyyy-MM-dd");
  186 + const QDate current = QDate::currentDate();
  187 + int age = current.year() - dob.year();
  188 + if (current.month() < dob.month()) age--;
  189 + t.file.insert("Age", age);
  190 + }
  191 +
182 return t; 192 return t;
183 } 193 }
184 }; 194 };