tools: Showing ExpirationPeriod if it is present in FaceStatus

Change-Id: I8e5b1350179830a1d12866c02c16393068e06369
Refs: #1686
diff --git a/daemon/face/udp-face.cpp b/daemon/face/udp-face.cpp
index d4fe8cf..843d48f 100644
--- a/daemon/face/udp-face.cpp
+++ b/daemon/face/udp-face.cpp
@@ -103,8 +103,10 @@
 {
   ndn::nfd::FaceStatus status = Face::getFaceStatus();
   if (isOnDemand()) {
-    time::milliseconds left = time::duration_cast<time::milliseconds>(
+    time::milliseconds left = m_idleTimeout - time::duration_cast<time::milliseconds>(
       time::steady_clock::now() - m_lastIdleCheck);
+    if (left < time::milliseconds::zero())
+      left = time::milliseconds::zero();
 
     if (hasBeenUsedRecently()) {
       status.setExpirationPeriod(left + m_idleTimeout);
diff --git a/docs/_static/nfd-status.xsd b/docs/_static/nfd-status.xsd
index 8f9f7cf..829ba7c 100644
--- a/docs/_static/nfd-status.xsd
+++ b/docs/_static/nfd-status.xsd
@@ -57,6 +57,7 @@
     <xs:element type="xs:nonNegativeInteger" name="faceId"/>
     <xs:element type="xs:anyURI" name="remoteUri"/>
     <xs:element type="xs:anyURI" name="localUri"/>
+    <xs:element type="xs:duration" name="expirationPeriod" maxOccurs="1" minOccurs="0"/>
     <xs:element type="nfd:bidirectionalPacketCountersType" name="packetCounters"/>
     <xs:element type="nfd:faceFlagsType" name="flags" maxOccurs="1" minOccurs="0"/>
   </xs:sequence>
diff --git a/tools/nfd-status.cpp b/tools/nfd-status.cpp
index 5d35108..d06e8fb 100644
--- a/tools/nfd-status.cpp
+++ b/tools/nfd-status.cpp
@@ -369,6 +369,14 @@
             std::string localUri(faceStatus.getLocalUri());
             escapeSpecialCharacters(&localUri);
             std::cout << "<localUri>" << localUri << "</localUri>";
+
+            if (faceStatus.hasExpirationPeriod()) {
+              std::cout << "<expirationPeriod>PT"
+                        << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
+                             .count() << "S"
+                        << "</expirationPeriod>";
+            }
+
             std::cout << "<packetCounters>";
             std::cout << "<incomingPackets>";
             std::cout << "<nInterests>"       << faceStatus.getNInInterests()
@@ -419,8 +427,13 @@
 
             std::cout << "  faceid=" << faceStatus.getFaceId()
                       << " remote=" << faceStatus.getRemoteUri()
-                      << " local=" << faceStatus.getLocalUri()
-                      << " counters={"
+                      << " local=" << faceStatus.getLocalUri();
+            if (faceStatus.hasExpirationPeriod()) {
+              std::cout  << " expires="
+                         << time::duration_cast<time::seconds>(faceStatus.getExpirationPeriod())
+                              .count() << "s";
+            }
+            std::cout << " counters={"
                       << "in={" << faceStatus.getNInInterests() << "i "
                       << faceStatus.getNInDatas() << "d}"
                       << " out={" << faceStatus.getNOutInterests() << "i "