summaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-11 12:10:14 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-11 12:10:14 -0500
commitf729e1e984896a9d6852768a8e5528932f668ac3 (patch)
treef6e1aa68ec9e5f6875a06224333b96b8f7938b2e /src/common/util.c
parentf37181620951d2e7a13f1363386563115d628761 (diff)
parentb5af456685b502462385b5f1b7f22f4374822fe1 (diff)
downloadtor-f729e1e984896a9d6852768a8e5528932f668ac3.tar.gz
tor-f729e1e984896a9d6852768a8e5528932f668ac3.zip
Merge branch 'feature3457-v4-nm-squashed'
Conflicts: src/or/rendclient.c
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 6d488d9963..22c816abcc 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1430,6 +1430,26 @@ format_iso_time(char *buf, time_t t)
strftime(buf, ISO_TIME_LEN+1, "%Y-%m-%d %H:%M:%S", tor_gmtime_r(&t, &tm));
}
+/** As format_iso_time, but use the yyyy-mm-ddThh:mm:ss format to avoid
+ * embedding an internal space. */
+void
+format_iso_time_nospace(char *buf, time_t t)
+{
+ format_iso_time(buf, t);
+ buf[10] = 'T';
+}
+
+/** As format_iso_time_nospace, but include microseconds in decimal
+ * fixed-point format. Requires that buf be at least ISO_TIME_USEC_LEN+1
+ * bytes long. */
+void
+format_iso_time_nospace_usec(char *buf, const struct timeval *tv)
+{
+ tor_assert(tv);
+ format_iso_time_nospace(buf, tv->tv_sec);
+ tor_snprintf(buf+ISO_TIME_LEN, 8, ".%06d", (int)tv->tv_usec);
+}
+
/** Given an ISO-formatted UTC time value (after the epoch) in <b>cp</b>,
* parse it and store its value in *<b>t</b>. Return 0 on success, -1 on
* failure. Ignore extraneous stuff in <b>cp</b> separated by whitespace from