util: add literal operators for duration types

Change-Id: I007fa61c80e535c6e4b12e85a32eeeee62fecc3c
Refs: #4468
diff --git a/src/util/notification-stream.hpp b/src/util/notification-stream.hpp
index 1c7887e..5dcf25a 100644
--- a/src/util/notification-stream.hpp
+++ b/src/util/notification-stream.hpp
@@ -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,
@@ -28,11 +28,10 @@
 #ifndef NDN_UTIL_NOTIFICATION_STREAM_HPP
 #define NDN_UTIL_NOTIFICATION_STREAM_HPP
 
-#include "../name.hpp"
-#include "../face.hpp"
-#include "../security/v2/key-chain.hpp"
-
 #include "concepts.hpp"
+#include "../face.hpp"
+#include "../name.hpp"
+#include "../security/v2/key-chain.hpp"
 
 namespace ndn {
 namespace util {
@@ -65,7 +64,7 @@
 
     shared_ptr<Data> data = make_shared<Data>(dataName);
     data->setContent(notification.wireEncode());
-    data->setFreshnessPeriod(time::seconds(1));
+    data->setFreshnessPeriod(1_s);
 
     m_keyChain.sign(*data);
     m_face.put(*data);
diff --git a/src/util/notification-subscriber.hpp b/src/util/notification-subscriber.hpp
index be36d31..2791ff5 100644
--- a/src/util/notification-subscriber.hpp
+++ b/src/util/notification-subscriber.hpp
@@ -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,
@@ -157,7 +157,7 @@
    *        User should add one or more handlers to onNotification, and invoke .start().
    */
   NotificationSubscriber(Face& face, const Name& prefix,
-                         time::milliseconds interestLifetime = time::seconds(60))
+                         time::milliseconds interestLifetime = 1_min)
     : NotificationSubscriberBase(face, prefix, interestLifetime)
   {
   }
diff --git a/src/util/segment-fetcher.hpp b/src/util/segment-fetcher.hpp
index cc9725a..cec29b7 100644
--- a/src/util/segment-fetcher.hpp
+++ b/src/util/segment-fetcher.hpp
@@ -93,7 +93,7 @@
  *     }
  *
  *     ...
- *     SegmentFetcher::fetch(face, Interest("/data/prefix", time::seconds(1000)),
+ *     SegmentFetcher::fetch(face, Interest("/data/prefix", 30_s),
  *                           validator,
  *                           bind(&afterFetchComplete, this, _1),
  *                           bind(&afterFetchError, this, _1, _2));
diff --git a/src/util/time.hpp b/src/util/time.hpp
index 29274a5..cf497af 100644
--- a/src/util/time.hpp
+++ b/src/util/time.hpp
@@ -53,6 +53,114 @@
   return d >= d.zero() ? d : -d;
 }
 
+} // namespace time
+
+inline namespace literals {
+inline namespace time_literals {
+
+constexpr time::days
+operator "" _day(unsigned long long days)
+{
+  return time::days{days};
+}
+
+constexpr time::duration<long double, time::days::period>
+operator "" _day(long double days)
+{
+  return time::duration<long double, time::days::period>{days};
+}
+
+constexpr time::days
+operator "" _days(unsigned long long days)
+{
+  return time::days{days};
+}
+
+constexpr time::duration<long double, time::days::period>
+operator "" _days(long double days)
+{
+  return time::duration<long double, time::days::period>{days};
+}
+
+constexpr time::hours
+operator "" _h(unsigned long long hrs)
+{
+  return time::hours{hrs};
+}
+
+constexpr time::duration<long double, time::hours::period>
+operator "" _h(long double hrs)
+{
+  return time::duration<long double, time::hours::period>{hrs};
+}
+
+constexpr time::minutes
+operator "" _min(unsigned long long mins)
+{
+  return time::minutes{mins};
+}
+
+constexpr time::duration<long double, time::minutes::period>
+operator "" _min(long double mins)
+{
+  return time::duration<long double, time::minutes::period>{mins};
+}
+
+constexpr time::seconds
+operator "" _s(unsigned long long secs)
+{
+  return time::seconds{secs};
+}
+
+constexpr time::duration<long double, time::seconds::period>
+operator "" _s(long double secs)
+{
+  return time::duration<long double, time::seconds::period>{secs};
+}
+
+constexpr time::milliseconds
+operator "" _ms(unsigned long long msecs)
+{
+  return time::milliseconds{msecs};
+}
+
+constexpr time::duration<long double, time::milliseconds::period>
+operator "" _ms(long double msecs)
+{
+  return time::duration<long double, time::milliseconds::period>{msecs};
+}
+
+constexpr time::microseconds
+operator "" _us(unsigned long long usecs)
+{
+  return time::microseconds{usecs};
+}
+
+constexpr time::duration<long double, time::microseconds::period>
+operator "" _us(long double usecs)
+{
+  return time::duration<long double, time::microseconds::period>{usecs};
+}
+
+constexpr time::nanoseconds
+operator "" _ns(unsigned long long nsecs)
+{
+  return time::nanoseconds{nsecs};
+}
+
+constexpr time::duration<long double, time::nanoseconds::period>
+operator "" _ns(long double nsecs)
+{
+  return time::duration<long double, time::nanoseconds::period>{nsecs};
+}
+
+} // inline namespace time_literals
+} // inline namespace literals
+
+namespace time {
+
+using namespace literals::time_literals;
+
 /**
  * \brief System clock
  *