diff options
author | randomdan <randomdan@localhost> | 2011-10-04 00:43:38 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-10-04 00:43:38 +0000 |
commit | 3dc2cd9884f6a0bdebe68415708e70831d448b44 (patch) | |
tree | 14e1a7c645bd0068a5a549a87ff8618be2013c25 | |
parent | Empty the XSL row cache on iteration (diff) | |
download | project2-3dc2cd9884f6a0bdebe68415708e70831d448b44.tar.bz2 project2-3dc2cd9884f6a0bdebe68415708e70831d448b44.tar.xz project2-3dc2cd9884f6a0bdebe68415708e70831d448b44.zip |
Include broken down date and time parts in XML output
-rw-r--r-- | project2/xml/Jamfile.jam | 2 | ||||
-rw-r--r-- | project2/xml/xmlPresenter.cpp | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/project2/xml/Jamfile.jam b/project2/xml/Jamfile.jam index be45dc6..8a4a5cc 100644 --- a/project2/xml/Jamfile.jam +++ b/project2/xml/Jamfile.jam @@ -5,6 +5,7 @@ alias libxslt : : : : <cflags>"`pkg-config --cflags libexslt`" <linkflags>"`pkg-config --libs libexslt`" ; lib boost_filesystem : : <name>boost_filesystem ; +lib boost_date_time : : <name>boost_date_time ; cpp-pch pch : pch.hpp : <include>../../libmisc @@ -23,6 +24,7 @@ lib p2xml : <library>../url//p2url <library>libxslt <library>boost_filesystem + <library>boost_date_time : : <library>../uuid//p2uuid <include>. diff --git a/project2/xml/xmlPresenter.cpp b/project2/xml/xmlPresenter.cpp index 6d4ddeb..58321ba 100644 --- a/project2/xml/xmlPresenter.cpp +++ b/project2/xml/xmlPresenter.cpp @@ -4,6 +4,8 @@ #include "variables.h" #include "appEngine.h" #include <libxml++/document.h> +#include <boost/date_time/posix_time/time_formatters.hpp> +#include <boost/date_time/gregorian/formatters.hpp> DECLARE_COMPONENT_LOADER("xml", XmlPresenter, PresenterLoader) @@ -87,6 +89,11 @@ XmlPresenter::addText(const VariableType & value) const { if (!value.get<Null>()) { nodeStack.back()->add_child_text(value); + // Special cases + if (const boost::posix_time::ptime * dt = value.get<boost::posix_time::ptime>()) { + nodeStack.back()->set_attribute("time", boost::posix_time::to_simple_string(dt->time_of_day())); + nodeStack.back()->set_attribute("date", boost::gregorian::to_iso_extended_string(dt->date())); + } } } |