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/configure b/configure
index f72da90..39c92e9 100755
--- a/configure
+++ b/configure
@@ -2278,6 +2278,97 @@
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_cxx_check_func
+
+# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES
+# ---------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_cxx_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval \${$3+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ---------------------------------------- ##
+## Report this to ndn-lib@lists.cs.ucla.edu ##
+## ---------------------------------------- ##"
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_cxx_check_header_mongrel
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -16150,36 +16241,69 @@
 ;;
   esac
 
-for ac_func in memcmp
+for ac_func in memcmp memcpy memset
 do :
-  ac_fn_cxx_check_func "$LINENO" "memcmp" "ac_cv_func_memcmp"
-if test "x$ac_cv_func_memcmp" = xyes; then :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_MEMCMP 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
 _ACEOF
 
 fi
 done
 
-for ac_func in memcpy
+for ac_func in strchr
 do :
-  ac_fn_cxx_check_func "$LINENO" "memcpy" "ac_cv_func_memcpy"
-if test "x$ac_cv_func_memcpy" = xyes; then :
+  ac_fn_cxx_check_func "$LINENO" "strchr" "ac_cv_func_strchr"
+if test "x$ac_cv_func_strchr" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_MEMCPY 1
+#define HAVE_STRCHR 1
 _ACEOF
-
+ :
+else
+  as_fn_error $? "*** strchr not found. Check 'config.log' for more details." "$LINENO" 5
 fi
 done
 
-for ac_func in memset
+for ac_func in sscanf
 do :
-  ac_fn_cxx_check_func "$LINENO" "memset" "ac_cv_func_memset"
-if test "x$ac_cv_func_memset" = xyes; then :
+  ac_fn_cxx_check_func "$LINENO" "sscanf" "ac_cv_func_sscanf"
+if test "x$ac_cv_func_sscanf" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_MEMSET 1
+#define HAVE_SSCANF 1
 _ACEOF
+ :
+else
+  as_fn_error $? "*** sscanf not found. Check 'config.log' for more details." "$LINENO" 5
+fi
+done
 
+
+for ac_header in sys/time.h
+do :
+  ac_fn_cxx_check_header_mongrel "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_time_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_TIME_H 1
+_ACEOF
+ :
+else
+  as_fn_error $? "*** sys/time.h not found. Check 'config.log' for more details." "$LINENO" 5
+fi
+
+done
+
+for ac_func in gettimeofday
+do :
+  ac_fn_cxx_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday"
+if test "x$ac_cv_func_gettimeofday" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GETTIMEOFDAY 1
+_ACEOF
+ :
+else
+  as_fn_error $? "*** gettimeofday not found. processEvents requires it. Check 'config.log' for more details." "$LINENO" 5
 fi
 done
 
@@ -16546,6 +16670,48 @@
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gmtime support" >&5
+$as_echo_n "checking for gmtime support... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/time.h>
+    struct timeval tv;
+    int result1 = gettimeofday(&tv, 0);
+    time_t time1 = time(0);
+    struct tm* tm1 = gmtime(&time1);
+    time_t time2 = timegm(tm1);
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GMTIME_SUPPORT 1
+_ACEOF
+
+
+else
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_GMTIME_SUPPORT 0
+_ACEOF
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 # Require libcrypto.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_EncryptInit in -lcrypto" >&5
 $as_echo_n "checking for EVP_EncryptInit in -lcrypto... " >&6; }
diff --git a/configure.ac b/configure.ac
index 6700637..ebd0565 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,9 +56,11 @@
 AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
-AC_CHECK_FUNCS([memcmp])
-AC_CHECK_FUNCS([memcpy])
-AC_CHECK_FUNCS([memset])
+AC_CHECK_FUNCS([memcmp] [memcpy] [memset])
+AC_CHECK_FUNCS([strchr], :, AC_MSG_ERROR([*** strchr not found. Check 'config.log' for more details.]))
+AC_CHECK_FUNCS([sscanf], :, AC_MSG_ERROR([*** sscanf not found. Check 'config.log' for more details.]))
+AC_CHECK_HEADERS([sys/time.h], :, AC_MSG_ERROR([*** sys/time.h not found. Check 'config.log' for more details.]))
+AC_CHECK_FUNCS([gettimeofday], :, AC_MSG_ERROR([*** gettimeofday not found. processEvents requires it. Check 'config.log' for more details.]))
 AX_CXX_COMPILE_STDCXX_11(, optional)
 AC_C_INLINE
 
@@ -108,6 +110,22 @@
     AC_DEFINE_UNQUOTED([HAVE_BOOST_FUNCTION], 0, [1 if have the `boost::function' class.])
 ])
 
+AC_MSG_CHECKING([for gmtime support])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+    [[#include <sys/time.h>]]
+    [[struct timeval tv;]]
+    [[int result1 = gettimeofday(&tv, 0);]]
+    [[time_t time1 = time(0);]]
+    [[struct tm* tm1 = gmtime(&time1);]]
+    [[time_t time2 = timegm(tm1);]])
+], [
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED([HAVE_GMTIME_SUPPORT], 1, [1 if have sys/time gmtime support including timegm.])
+], [
+    AC_MSG_RESULT([no])
+    AC_DEFINE_UNQUOTED([HAVE_GMTIME_SUPPORT], 0, [1 if have sys/time gmtime support including timegm.])
+])
+
 # Require libcrypto.
 AC_CHECK_LIB([crypto], [EVP_EncryptInit], [],
              [AC_MSG_FAILURE([can't find openssl crypto lib])])
diff --git a/include/config.h.in b/include/config.h.in
index 203a519..7621126 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -12,6 +12,12 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* 1 if have sys/time gmtime support including timegm. */
+#undef HAVE_GMTIME_SUPPORT
+
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
@@ -39,6 +45,9 @@
 /* Have the SQLITE3 library */
 #undef HAVE_SQLITE3
 
+/* Define to 1 if you have the `sscanf' function. */
+#undef HAVE_SSCANF
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
@@ -51,6 +60,9 @@
 /* 1 if have the `std::shared_ptr' class. */
 #undef HAVE_STD_SHARED_PTR
 
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
 /* Define to 1 if you have the <strings.h> header file. */
 #undef HAVE_STRINGS_H
 
@@ -60,6 +72,9 @@
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
diff --git a/ndn-cpp/c/errors.c b/ndn-cpp/c/errors.c
index 55ae58d..a77a858 100644
--- a/ndn-cpp/c/errors.c
+++ b/ndn-cpp/c/errors.c
@@ -75,6 +75,8 @@
     return      "SocketTransport error in close";
   case NDN_ERROR_Name_component_does_not_begin_with_the_expected_marker:
     return      "Name component does not begin with the expected marker";
+  case NDN_ERROR_Time_functions_are_not_supported_by_the_standard_library:
+    return      "Time functions are not supported by the standard library";
   default:
     return "unrecognized ndn_Error code";  
   }
diff --git a/ndn-cpp/c/errors.h b/ndn-cpp/c/errors.h
index f975c26..396f43d 100644
--- a/ndn-cpp/c/errors.h
+++ b/ndn-cpp/c/errors.h
@@ -45,7 +45,8 @@
   NDN_ERROR_SocketTransport_error_in_poll,
   NDN_ERROR_SocketTransport_error_in_recv,
   NDN_ERROR_SocketTransport_error_in_close,
-  NDN_ERROR_Name_component_does_not_begin_with_the_expected_marker
+  NDN_ERROR_Name_component_does_not_begin_with_the_expected_marker,
+  NDN_ERROR_Time_functions_are_not_supported_by_the_standard_library
 } ndn_Error;
   
 /**
diff --git a/ndn-cpp/c/util/time.c b/ndn-cpp/c/util/time.c
index 7ffa517..b7de490 100644
--- a/ndn-cpp/c/util/time.c
+++ b/ndn-cpp/c/util/time.c
@@ -14,14 +14,16 @@
 ndn_getNowMilliseconds()
 {
   struct timeval t;
+  // Note: configure.ac requires gettimeofday.
   gettimeofday(&t, 0);
   return t.tv_sec * 1000.0 + t.tv_usec / 1000.0;
 }
 
-void
-ndn_toIsoString(ndn_MillisecondsSince1970 time, char *isoString)
+ndn_Error
+ndn_toIsoString(ndn_MillisecondsSince1970 milliseconds, char *isoString)
 {
-  double secondsSince1970 = time / 1000.0;
+#if NDN_CPP_HAVE_GMTIME_SUPPORT
+  double secondsSince1970 = milliseconds / 1000.0;
   char fractionBuffer[10];
   sprintf(fractionBuffer, "%.06lf", fmod(secondsSince1970, 1.0));
   const char *fraction = strchr(fractionBuffer, '.');
@@ -33,24 +35,35 @@
   struct tm* gmt = gmtime(&seconds);
   sprintf(isoString, "%04d%02d%02dT%02d%02d%02d%s", 1900 + gmt->tm_year, gmt->tm_mon + 1, gmt->tm_mday,
     gmt->tm_hour, gmt->tm_min, gmt->tm_sec, fraction);
+  
+  return NDN_ERROR_success;
+#else
+  return NDN_ERROR_Time_functions_are_not_supported_by_the_standard_library;
+#endif
 }
 
-ndn_MillisecondsSince1970
-ndn_fromIsoString(const char* isoString)
+ndn_Error
+ndn_fromIsoString(const char* isoString, ndn_MillisecondsSince1970 *milliseconds)
 {
+#if NDN_CPP_HAVE_GMTIME_SUPPORT
   // Initialize time zone, etc.
   time_t dummyTime = 0;
-  struct tm time = *gmtime(&dummyTime);
+  struct tm tm1 = *gmtime(&dummyTime);
   
-  sscanf(isoString, "%4d%2d%2dT%2d%2d", &time.tm_year, &time.tm_mon, &time.tm_mday, &time.tm_hour, &time.tm_min);
+  sscanf(isoString, "%4d%2d%2dT%2d%2d", &tm1.tm_year, &tm1.tm_mon, &tm1.tm_mday, &tm1.tm_hour, &tm1.tm_min);
   // Skip the time past minutes and get the float seconds.
   double seconds;
   sscanf(isoString + (4 + 2 + 2 + 1 + 2 + 2), "%lf", &seconds);
   
   // tm_year starts from 1900.
-  time.tm_year -= 1900;
+  tm1.tm_year -= 1900;
   // tm_mon starts from 0, not 1.
-  time.tm_mon -= 1;
-  time.tm_sec = 0;
-  return (timegm(&time) + seconds) * 1000.0;  
-}
\ No newline at end of file
+  tm1.tm_mon -= 1;
+  tm1.tm_sec = 0;
+  
+  *milliseconds = (timegm(&tm1) + seconds) * 1000.0;
+  return NDN_ERROR_success;
+#else
+  return NDN_ERROR_Time_functions_are_not_supported_by_the_standard_library;
+#endif
+}
diff --git a/ndn-cpp/c/util/time.h b/ndn-cpp/c/util/time.h
index b2414c7..75f95df 100644
--- a/ndn-cpp/c/util/time.h
+++ b/ndn-cpp/c/util/time.h
@@ -8,6 +8,7 @@
 #define NDN_TIME_H
 
 #include <ndn-cpp/c/common.h>
+#include "../errors.h"
 
 #ifdef  __cplusplus
 extern "C" {
@@ -24,17 +25,19 @@
  * Convert the time from milliseconds to an ISO time string, for example "20131018T184138.423355".
  * @param milliseconds The time in milliseconds since 1/1/1970, including fractions of a millisecond.
  * @param isoString A buffer of at least 23 bytes to receive the null-terminated ISO time string.
+ * @return 0 for success, else an error code including if we don't have necessary standard library support.
  */
-void
-ndn_toIsoString(ndn_MillisecondsSince1970 time, char *isoString);
+ndn_Error
+ndn_toIsoString(ndn_MillisecondsSince1970 milliseconds, char *isoString);
 
 /**
  * Parse the ISO time string and return the time in milliseconds.
  * @param isoString The ISO time string, for example "20131018T184138.423355".
- * @return The time in milliseconds since 1/1/1970, including fractions of a millisecond.
+ * @param milliseconds Return the time in milliseconds since 1/1/1970, including fractions of a millisecond.
+ * @return 0 for success, else an error code including if we don't have necessary standard library support.
  */
-ndn_MillisecondsSince1970
-ndn_fromIsoString(const char* isoString);
+ndn_Error
+ndn_fromIsoString(const char* isoString, ndn_MillisecondsSince1970 *milliseconds);
 
 #ifdef  __cplusplus
 }
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