time support: check and define NDN_CPP_HAVE_GMTIME_SUPPORT. In ndn_toIsoString and ndn_fromIsoString, return an error if not supported.
diff --git a/ndn-cpp/encoding/der/der.cpp b/ndn-cpp/encoding/der/der.cpp
index 9d3258c..6d269c1 100644
--- a/ndn-cpp/encoding/der/der.cpp
+++ b/ndn-cpp/encoding/der/der.cpp
@@ -6,6 +6,7 @@
* See COPYING for copyright and distribution information.
*/
+#include <stdexcept>
#include "der-exception.hpp"
#include "../../util/logging.hpp"
#include "../../c/util/time.h"
@@ -595,13 +596,21 @@
string DerGtime::toIsoString(const MillisecondsSince1970& time)
{
char isoString[25];
- ndn_toIsoString(time, isoString);
+ ndn_Error error;
+ if ((error = ndn_toIsoString(time, isoString)))
+ throw runtime_error(ndn_getErrorString(error));
+
return isoString;
}
MillisecondsSince1970 DerGtime::fromIsoString(const string& isoString)
{
- return ndn_fromIsoString(isoString.c_str());
+ MillisecondsSince1970 milliseconds;
+ ndn_Error error;
+ if ((error = ndn_fromIsoString(isoString.c_str(), &milliseconds)))
+ throw runtime_error(ndn_getErrorString(error));
+
+ return milliseconds;
}
} // der