tools: add congestion marking parameters to nfdc face create

refs #4465

Change-Id: I5df5d6136f4729ad836a72f55531208d868da5f7
diff --git a/tools/nfdc/format-helpers.cpp b/tools/nfdc/format-helpers.cpp
index 3d851dd..6d5a983 100644
--- a/tools/nfdc/format-helpers.cpp
+++ b/tools/nfdc/format-helpers.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -25,6 +25,9 @@
 
 #include "format-helpers.hpp"
 
+#include <iomanip>
+#include <sstream>
+
 namespace nfd {
 namespace tools {
 namespace nfdc {
@@ -73,9 +76,28 @@
 }
 
 std::string
-formatSeconds(time::seconds d)
+formatDuration(time::nanoseconds d)
 {
-  return "PT" + to_string(d.count()) + "S";
+  std::ostringstream str;
+
+  if (d < 0_ns) {
+    str << "-";
+  }
+
+  str << "PT";
+
+  time::seconds seconds(time::duration_cast<time::seconds>(time::abs(d)));
+  time::milliseconds ms(time::duration_cast<time::milliseconds>(time::abs(d) - seconds));
+
+  str << seconds.count();
+
+  if (ms >= 1_ms) {
+    str << "." << std::setfill('0') << std::setw(3) << ms.count();
+  }
+
+  str << "S";
+
+  return str.str();
 }
 
 std::string
@@ -156,12 +178,6 @@
 }
 
 std::string
-formatSeconds(time::seconds d, bool isLong)
-{
-  return to_string(d.count()) + (isLong ? " seconds" : "s");
-}
-
-std::string
 formatTimestamp(time::system_clock::TimePoint t)
 {
   return time::toIsoString(t);