From 844b643552e3b5cabeeafe1a04802dca5c3df018 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Sun, 13 Jan 2013 15:34:34 -0500 Subject: [PATCH] added age calculation --- sdk/plugins/format.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+), 0 deletions(-) diff --git a/sdk/plugins/format.cpp b/sdk/plugins/format.cpp index daf901b..9e1e7b2 100644 --- a/sdk/plugins/format.cpp +++ b/sdk/plugins/format.cpp @@ -14,6 +14,7 @@ * limitations under the License. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #ifndef BR_EMBEDDED #include #include @@ -179,6 +180,15 @@ class xmlFormat : public Format subject = subject.nextSibling(); } + // Calculate age + if (t.file.contains("DOB")) { + const QDate dob = QDate::fromString(t.file.getString("DOB").left(10), "yyyy-MM-dd"); + const QDate current = QDate::currentDate(); + int age = current.year() - dob.year(); + if (current.month() < dob.month()) age--; + t.file.insert("Age", age); + } + return t; } }; -- libgit2 0.21.4