ofp-util: New function ofputil_encode_barrier_request().
[openvswitch] / lib / dynamic-string.c
index dbb33a3563304cfec53e5505598096ef35e132d2..8c675d14a63ddacd6b7ce56878a4a4b2baa6eeb1 100644 (file)
@@ -173,13 +173,19 @@ ds_put_printable(struct ds *ds, const char *s, size_t n)
     }
 }
 
+/* Writes the current time to 'string' based on 'template'.
+ * The current time is either localtime or UTC based on 'utc'. */
 void
-ds_put_strftime(struct ds *ds, const char *template, const struct tm *tm)
+ds_put_strftime(struct ds *ds, const char *template, bool utc)
 {
-    if (!tm) {
-        time_t now = time_wall();
+    const struct tm *tm;
+    time_t now = time_wall();
+    if (utc) {
+        tm = gmtime(&now);
+    } else {
         tm = localtime(&now);
     }
+
     for (;;) {
         size_t avail = ds->string ? ds->allocated - ds->length + 1 : 0;
         size_t used = strftime(&ds->string[ds->length], avail, template, tm);