all: Refactoring work with time using boost::chrono

Now the library has two clocks: time::steady_clock and
time::system_clock, following (boost|std)::chrono.  In addition to
standard now() method, the library contains several helpers to convert
to/from UnixTimestamp (microsecond resolution) and IsoString (optional
microsecond resolution).  The IsoString conversions use
boost::posix_time routines, since boost::chrono supports extended IO
support only starting boost version 1.52 (Boost Chrono V2).

This commit breaks compatibility with previous API.  All time-related
Data/Interest calls must explicitly use time units to specify
FreshnessPeriod/InterestLifetime.

Brief usage/conversion guide:

- creation of time units does not support double/float types.  If
  necessary to create time unit from double, ``ndn::duration<double>`` (for
  seconds) needs to be used instead.  In some cases, this would also
  require ``ndn::duration_cast``, if the target is not ``ndn::nanoseconds``.
- ndn::getNow, ndn::ndn_getNowMilliseconds, ndn::time::now are all
  removed in favor of the now() method in a specific clock:

    * time::system_clock::now();
    * time::steady_clock::now();

- When necessary to convert system_clock::TimePoint to unix timestamp,
  ``time::toUnixTimestamp`` can be used.  This method return number of
  milliseconds since UNIX epoch as ``ndn::time::milliseconds`` type.
  Use count() method to obtain number as an integral value.

Change-Id: Icd688bc6766e008d60c3d2888173627874526e47
Refs: #1152
diff --git a/tests/management/nfd-status.cpp b/tests/management/nfd-status.cpp
index b5d408c..ef411a4 100644
--- a/tests/management/nfd-status.cpp
+++ b/tests/management/nfd-status.cpp
@@ -18,8 +18,8 @@
 {
   Status status1;
   status1.setNfdVersion(1014210635);
-  status1.setStartTimestamp(Status::Timestamp(boost::chrono::seconds(375193249)));
-  status1.setCurrentTimestamp(Status::Timestamp(boost::chrono::seconds(1886109034)));
+  status1.setStartTimestamp(time::fromUnixTimestamp(time::seconds(375193249)));
+  status1.setCurrentTimestamp(time::fromUnixTimestamp(time::seconds(1886109034)));
   status1.setNNameTreeEntries(1849943160);
   status1.setNFibEntries(621739748);
   status1.setNPitEntries(482129741);
diff --git a/tests/management/test-ndnd-forwarding-entry.cpp b/tests/management/test-ndnd-forwarding-entry.cpp
index 1c1afb8..7ad5c94 100644
--- a/tests/management/test-ndnd-forwarding-entry.cpp
+++ b/tests/management/test-ndnd-forwarding-entry.cpp
@@ -30,7 +30,7 @@
 
 BOOST_AUTO_TEST_CASE (Encode)
 {
-  ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), -1);
+  ForwardingEntry forwardingEntry("selfreg", "/a/prefix", -1, ForwardingFlags(), time::milliseconds::min());
   const Block &wire = forwardingEntry.wireEncode();
 
   BOOST_REQUIRE_EQUAL_COLLECTIONS(FORWARDING_ENTRY, FORWARDING_ENTRY+sizeof(FORWARDING_ENTRY),
@@ -54,7 +54,7 @@
   BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getLocal(), false);
   BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getTap(), false);
   BOOST_REQUIRE_EQUAL(forwardingEntry.getForwardingFlags().getCaptureOk(), false);
-  BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), -1);
+  BOOST_REQUIRE_EQUAL(forwardingEntry.getFreshnessPeriod(), time::milliseconds::min());
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/management/test-nrd.cpp b/tests/management/test-nrd.cpp
index de95ee2..92622f0 100644
--- a/tests/management/test-nrd.cpp
+++ b/tests/management/test-nrd.cpp
@@ -39,7 +39,7 @@
   std::ostringstream os;
   os << opt;
   BOOST_CHECK_EQUAL(os.str(), "PrefixRegOptions(Prefix: /localhost/reg/test, "
-                    "FaceID: 0, Flags: 1, Cost: 0, ExpirationPeriod: -1, Protocol: )");
+                    "FaceID: 0, Flags: 1, Cost: 0, ExpirationPeriod: -9223372036854775808 milliseconds, Protocol: )");
 }
 
 BOOST_AUTO_TEST_CASE (PrefixRegOptionsDecoding)
diff --git a/tests/security/test-certificate-cache.cpp b/tests/security/test-certificate-cache.cpp
index 3718170..ee7fd6f 100644
--- a/tests/security/test-certificate-cache.cpp
+++ b/tests/security/test-certificate-cache.cpp
@@ -25,17 +25,17 @@
 BOOST_AUTO_TEST_CASE (Ttl)
 {
   shared_ptr<boost::asio::io_service> io = make_shared<boost::asio::io_service>();
-  shared_ptr<CertificateCacheTtl> cache = make_shared<CertificateCacheTtl>(io, 1);
+  shared_ptr<CertificateCacheTtl> cache = make_shared<CertificateCacheTtl>(io, time::seconds(1));
   Scheduler scheduler(*io);
 
   shared_ptr<IdentityCertificate> cert1 = make_shared<IdentityCertificate>();
   Name certName1("/tmp/KEY/ksk-1/ID-CERT/1");
   cert1->setName(certName1);
-  cert1->setFreshnessPeriod(500);
+  cert1->setFreshnessPeriod(time::milliseconds(500));
   shared_ptr<IdentityCertificate> cert2 = make_shared<IdentityCertificate>();
   Name certName2("/tmp/KEY/ksk-2/ID-CERT/2");
   cert2->setName(certName2);
-  cert2->setFreshnessPeriod(1000);
+  cert2->setFreshnessPeriod(time::milliseconds(1000));
 
   Name name1 = certName1.getPrefix(-1);
   Name name2 = certName2.getPrefix(-1);
@@ -43,13 +43,13 @@
   cache->insertCertificate(cert1);
   cache->insertCertificate(cert2);
 
-  scheduler.scheduleEvent(time::seconds(0.3), bind(&getCertificateTtl, cache, name1, true));
-  scheduler.scheduleEvent(time::seconds(0.3), bind(&getCertificateTtl, cache, name2, true));
-  scheduler.scheduleEvent(time::seconds(0.6), bind(&getCertificateTtl, cache, name1, false));
-  scheduler.scheduleEvent(time::seconds(0.6), bind(&getCertificateTtl, cache, name2, true));
-  scheduler.scheduleEvent(time::seconds(0.6), bind(&CertificateCache::insertCertificate, &*cache, cert2));
-  scheduler.scheduleEvent(time::seconds(1.3), bind(&getCertificateTtl, cache, name2, true));
-  scheduler.scheduleEvent(time::seconds(1.7), bind(&getCertificateTtl, cache, name2, false));
+  scheduler.scheduleEvent(time::milliseconds(300),  bind(&getCertificateTtl, cache, name1, true));
+  scheduler.scheduleEvent(time::milliseconds(300),  bind(&getCertificateTtl, cache, name2, true));
+  scheduler.scheduleEvent(time::milliseconds(600),  bind(&getCertificateTtl, cache, name1, false));
+  scheduler.scheduleEvent(time::milliseconds(600),  bind(&getCertificateTtl, cache, name2, true));
+  scheduler.scheduleEvent(time::milliseconds(600),  bind(&CertificateCache::insertCertificate, &*cache, cert2));
+  scheduler.scheduleEvent(time::milliseconds(1300), bind(&getCertificateTtl, cache, name2, true));
+  scheduler.scheduleEvent(time::milliseconds(1700), bind(&getCertificateTtl, cache, name2, false));
 
   io->run();
 }
diff --git a/tests/security/test-encode-decode-certificate.cpp b/tests/security/test-encode-decode-certificate.cpp
index 409e757..3b8cc83 100644
--- a/tests/security/test-encode-decode-certificate.cpp
+++ b/tests/security/test-encode-decode-certificate.cpp
@@ -83,8 +83,8 @@
 const std::string CERT_INFO = "Certificate name:\n"
   "  /\n"
   "Validity:\n"
-  "  NotBefore: 20131226T232254.000000\n"
-  "  NotAfter: 20131226T232254.000000\n"
+  "  NotBefore: 20131226T232254\n"
+  "  NotAfter: 20131226T232254\n"
   "Subject Description:\n"
   "  2.5.4.41: TEST NAME\n"
   "Public key bits:\n"
@@ -98,8 +98,8 @@
   ndn::Certificate c;
 
   // validity
-  c.setNotBefore(1388100174000); // 12/26/2013 @ 11:22pm
-  c.setNotAfter(1388100174000); // 12/26/2013 @ 11:22pm
+  c.setNotBefore(time::fromUnixTimestamp(time::milliseconds(1388100174000))); // 12/26/2013 @ 11:22pm
+  c.setNotAfter(time::fromUnixTimestamp(time::milliseconds(1388100174000))); // 12/26/2013 @ 11:22pm
 
   // subject
   c.addSubjectDescription(CertificateSubjectDescription("2.5.4.41", "TEST NAME"));
@@ -131,19 +131,19 @@
   // p.Load(source);
 
   BOOST_REQUIRE_NO_THROW(c.encode());
-  
+
   // ofstream of("cert.out");
   // of.write((const char*)c.getContent().value(), c.getContent().value_size());
   
   // const Block &wire = i.wireEncode();
   BOOST_REQUIRE_EQUAL_COLLECTIONS(CERT, CERT+sizeof(CERT),
-                                c.getContent().value_begin(), c.getContent().value_end());
+                                  c.getContent().value_begin(), c.getContent().value_end());
 
   std::ostringstream os;
   os << c << std::endl;
   std::string info(os.str());
-  BOOST_REQUIRE_EQUAL_COLLECTIONS(CERT_INFO.begin(), CERT_INFO.end(),
-                                  info.begin(), info.end());
+
+  BOOST_CHECK_EQUAL(CERT_INFO, info);
 }
 
 const unsigned char REAL_CERT[] = {
@@ -153,8 +153,8 @@
 const std::string REAL_CERT_INFO = "Certificate name:\n"
 "  /tmp\n"
 "Validity:\n"
-"  NotBefore: 20131101T171122.000000\n"
-"  NotAfter: 20141101T171122.000000\n"
+"  NotBefore: 20131101T171122\n"
+"  NotAfter: 20141101T171122\n"
 "Subject Description:\n"
 "  2.5.4.41: NDN Testbed Root\n"
 "Public key bits:\n"
@@ -176,8 +176,7 @@
   std::ostringstream os;
   os << c << std::endl;
   std::string info(os.str());
-  BOOST_REQUIRE_EQUAL_COLLECTIONS(REAL_CERT_INFO.begin(), REAL_CERT_INFO.end(),
-                                  info.begin(), info.end());
+  BOOST_CHECK_EQUAL(REAL_CERT_INFO, info);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/security/test-keychain.cpp b/tests/security/test-keychain.cpp
index 3e9b4fc..8a76b79 100644
--- a/tests/security/test-keychain.cpp
+++ b/tests/security/test-keychain.cpp
@@ -7,7 +7,6 @@
 #include <boost/test/unit_test.hpp>
 
 #include "security/key-chain.hpp"
-#include "util/time.hpp"
 
 using namespace std;
 
@@ -19,7 +18,8 @@
 {
   KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
 
-  Name identity(string("/TestKeyChain/ExportIdentity/") + boost::lexical_cast<std::string>(time::now()));
+  Name identity("/TestKeyChain/ExportIdentity/");
+  identity.appendVersion();
   keyChain.createIdentity(identity);
   
   shared_ptr<SecuredBag> exported = keyChain.exportIdentity(identity, "1234");
@@ -60,28 +60,30 @@
 {
   KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
   
-  Name identity(string("/TestKeyChain/PrepareIdentityCertificate/") + boost::lexical_cast<std::string>(time::now()));
+  Name identity("/TestKeyChain/PrepareIdentityCertificate/");
+  identity.appendVersion();
   keyChain.createIdentity(identity);
 
   vector<CertificateSubjectDescription> subjectDescription;
   Name lowerIdentity = identity;
-  lowerIdentity.append("Lower").append(boost::lexical_cast<std::string>(time::now()));
+  lowerIdentity.append("Lower").appendVersion();
   Name lowerKeyName = keyChain.generateRSAKeyPair(lowerIdentity, true);
   shared_ptr<IdentityCertificate> idCert
     = keyChain.prepareUnsignedIdentityCertificate(lowerKeyName, identity,
-						  time::now() / 1000000,
-						  time::now() / 1000000 + 630720000,
+						  time::system_clock::now(),
+						  time::system_clock::now() + time::days(365),
 						  subjectDescription);
   BOOST_CHECK(static_cast<bool>(idCert));
   BOOST_CHECK(idCert->getName().getPrefix(5) == Name().append(identity).append("KEY").append("Lower"));
 
 
-  Name anotherIdentity(string("/TestKeyChain/PrepareIdentityCertificate/Another/") + boost::lexical_cast<std::string>(time::now()));
+  Name anotherIdentity("/TestKeyChain/PrepareIdentityCertificate/Another/");
+  anotherIdentity.appendVersion();
   Name anotherKeyName = keyChain.generateRSAKeyPair(anotherIdentity, true);
   shared_ptr<IdentityCertificate> idCert2
     = keyChain.prepareUnsignedIdentityCertificate(anotherKeyName, identity,
-						  time::now() / 1000000,
-						  time::now() / 1000000 + 630720000,
+						  time::system_clock::now(),
+						  time::system_clock::now() + time::days(365),
 						  subjectDescription);
   BOOST_CHECK(static_cast<bool>(idCert2));
   BOOST_CHECK(idCert2->getName().getPrefix(5) == Name().append(anotherIdentity).append("KEY"));
@@ -90,8 +92,8 @@
   Name wrongKeyName1;
   shared_ptr<IdentityCertificate> idCert3
     = keyChain.prepareUnsignedIdentityCertificate(wrongKeyName1, identity,
-						  time::now() / 1000000,
-						  time::now() / 1000000 + 630720000,
+						  time::system_clock::now(),
+						  time::system_clock::now() + time::days(365),
 						  subjectDescription);
   BOOST_CHECK(!static_cast<bool>(idCert3));
 
@@ -99,8 +101,8 @@
   Name wrongKeyName2("/TestKeyChain/PrepareIdentityCertificate");
   shared_ptr<IdentityCertificate> idCert4
     = keyChain.prepareUnsignedIdentityCertificate(wrongKeyName2, identity,
-						  time::now() / 1000000,
-						  time::now() / 1000000 + 630720000,
+						  time::system_clock::now(),
+						  time::system_clock::now() + time::days(365),
 						  subjectDescription);
   BOOST_CHECK(!static_cast<bool>(idCert4));
   
@@ -108,8 +110,8 @@
   Name wrongKeyName3("/TestKeyChain/PrepareIdentityCertificate/ksk-1234");
   shared_ptr<IdentityCertificate> idCert5
     = keyChain.prepareUnsignedIdentityCertificate(wrongKeyName3, identity,
-						  time::now() / 1000000,
-						  time::now() / 1000000 + 630720000,
+						  time::system_clock::now(),
+						  time::system_clock::now() + time::days(365),
 						  subjectDescription);
   BOOST_CHECK(!static_cast<bool>(idCert5));
 
diff --git a/tests/security/test-sec-public-info-sqlite3.cpp b/tests/security/test-sec-public-info-sqlite3.cpp
index 8928ebf..c50183d 100644
--- a/tests/security/test-sec-public-info-sqlite3.cpp
+++ b/tests/security/test-sec-public-info-sqlite3.cpp
@@ -22,7 +22,9 @@
 {
   KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
 
-  Name identity("/TestSecPublicInfoSqlite3/Delete/" + boost::lexical_cast<string>(time::now()));
+  Name identity("/TestSecPublicInfoSqlite3/Delete");
+  identity.appendVersion();
+
   Name certName1;
   BOOST_REQUIRE_NO_THROW(certName1 = keyChain.createIdentity(identity));
 
diff --git a/tests/security/test-sec-tpm-file.cpp b/tests/security/test-sec-tpm-file.cpp
index 146a1e1..70fada8 100644
--- a/tests/security/test-sec-tpm-file.cpp
+++ b/tests/security/test-sec-tpm-file.cpp
@@ -24,7 +24,7 @@
 {
   SecTpmFile tpm;
   
-  Name keyName("/TestSecTpmFile/Delete/ksk-" + boost::lexical_cast<string>(time::now()));
+  Name keyName("/TestSecTpmFile/Delete/ksk-" + boost::lexical_cast<string>(time::toUnixTimestamp(time::system_clock::now())));
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
   
   BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
@@ -40,7 +40,7 @@
 {
   SecTpmFile tpm;
 
-  Name keyName("/TestSecTpmFile/SignVerify/ksk-" + boost::lexical_cast<string>(time::now()));
+  Name keyName("/TestSecTpmFile/SignVerify/ksk-" + boost::lexical_cast<string>(time::toUnixTimestamp(time::system_clock::now())));
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
   
   Data data("/tmp/test/1");
@@ -107,7 +107,7 @@
 
   SecTpmFile tpm;
 
-  Name keyName("/TestSecTpmFile/ImportKey/ksk-" + boost::lexical_cast<string>(time::now()));
+  Name keyName("/TestSecTpmFile/ImportKey/ksk-" + boost::lexical_cast<string>(time::toUnixTimestamp(time::system_clock::now())));
 
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
   BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
diff --git a/tests/security/test-sec-tpm-osx.cpp b/tests/security/test-sec-tpm-osx.cpp
index d75eec1..a08dc48 100644
--- a/tests/security/test-sec-tpm-osx.cpp
+++ b/tests/security/test-sec-tpm-osx.cpp
@@ -25,7 +25,8 @@
 {
   SecTpmOsx tpm;
   
-  Name keyName("/TestSecTpmOsx/Delete/ksk-" + boost::lexical_cast<string>(time::now()));
+  Name keyName("/TestSecTpmOsx/Delete/ksk-" + boost::lexical_cast<string>(
+                                                time::toUnixTimestamp(time::system_clock::now()).count()));
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
   
   BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
@@ -41,7 +42,8 @@
 {
   SecTpmOsx tpm;
 
-  Name keyName("/TestSecTpmOsx/SignVerify/ksk-" + boost::lexical_cast<string>(time::now()));
+  Name keyName("/TestSecTpmOsx/SignVerify/ksk-" + boost::lexical_cast<string>(
+                                                    time::toUnixTimestamp(time::system_clock::now()).count()));
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
   
   Data data("/TestSecTpmOsx/SignVaerify/Data/1");
@@ -102,7 +104,8 @@
 
   SecTpmOsx tpm;
 
-  Name keyName("/TestSecTpmOsx/ExportImportKey/ksk-" + boost::lexical_cast<string>(time::now()));
+  Name keyName("/TestSecTpmOsx/ExportImportKey/ksk-" + boost::lexical_cast<string>(
+                                                         time::toUnixTimestamp(time::system_clock::now()).count()));
   
   BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
 
diff --git a/tests/security/test-signed-interest.cpp b/tests/security/test-signed-interest.cpp
index f6898b9..db051c3 100644
--- a/tests/security/test-signed-interest.cpp
+++ b/tests/security/test-signed-interest.cpp
@@ -21,22 +21,24 @@
 {
   KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
 
-  Name identityName("/TestSignedInterest/SignVerify/" + boost::lexical_cast<string>(time::now()));
+  Name identityName("/TestSignedInterest/SignVerify");
+  identityName.appendVersion();
+
   Name certificateName;
   BOOST_REQUIRE_NO_THROW(certificateName = keyChain.createIdentity(identityName));
 
   Interest interest("/TestSignedInterest/SignVerify/Interest1");
   BOOST_CHECK_NO_THROW(keyChain.signByIdentity(interest, identityName));
-  
+
   Block interestBlock(interest.wireEncode().wire(), interest.wireEncode().size());
 
   Interest interest2;
   interest2.wireDecode(interestBlock);
-  
+
   shared_ptr<PublicKey> publicKey;
   BOOST_REQUIRE_NO_THROW(publicKey = keyChain.getPublicKeyFromTpm(keyChain.getDefaultKeyNameForIdentity(identityName)));
   bool result = Validator::verifySignature(interest2, *publicKey);
-  
+
   BOOST_CHECK_EQUAL(result, true);
 
   keyChain.deleteIdentity(identityName);
@@ -48,7 +50,7 @@
   CommandInterestFixture()
     : m_validity(false)
   {}
-  
+
   void
   validated(const shared_ptr<const Interest>& interest)
   { m_validity = true; }
@@ -56,7 +58,7 @@
   void
   validationFailed(const shared_ptr<const Interest>& interest, const string& failureInfo)
   {
-    m_validity = false; 
+    m_validity = false;
   }
 
   void
@@ -64,12 +66,14 @@
   { m_validity = false; }
 
   bool m_validity;
-}; 
+};
 
 BOOST_FIXTURE_TEST_CASE (CommandInterest, CommandInterestFixture)
 {
   KeyChain keyChain;
-  Name identity("/TestCommandInterest/Validation/" + boost::lexical_cast<string>(time::now()));
+  Name identity("/TestCommandInterest/Validation");
+  identity.appendVersion();
+
   Name certName;
   BOOST_REQUIRE_NO_THROW(certName = keyChain.createIdentity(identity));
 
@@ -84,38 +88,39 @@
   validator.validate(*commandInterest1,
   		     bind(&CommandInterestFixture::validated, this, _1),
   		     bind(&CommandInterestFixture::validationFailed, this, _1, _2));
-  
+
   BOOST_CHECK_EQUAL(m_validity, true);
-  
+
   //Test an outdated command
   reset();
   shared_ptr<Interest> commandInterest2 = make_shared<Interest>("/TestCommandInterest/Validation/Command2");
-  int64_t timestamp = time::now() / 1000000;
-  timestamp -= 5000;
+  time::milliseconds timestamp = time::toUnixTimestamp(time::system_clock::now());
+  timestamp -= time::seconds(5);
+
   Name commandName = commandInterest2->getName();
   commandName
-    .append(name::Component::fromNumber(timestamp))
-    .append(name::Component::fromNumber(random::generateWord64()));
+    .appendNumber(timestamp.count())
+    .appendNumber(random::generateWord64());
   commandInterest2->setName(commandName);
-  
+
   keyChain.signByIdentity(*commandInterest2, identity);
   validator.validate(*commandInterest2,
   		     bind(&CommandInterestFixture::validated, this, _1),
   		     bind(&CommandInterestFixture::validationFailed, this, _1, _2));
-  
+
   BOOST_CHECK_EQUAL(m_validity, false);
-  
+
   //Test an unauthorized command
   Name identity2("/TestCommandInterest/Validation2");
   Name certName2;
   BOOST_REQUIRE_NO_THROW(certName2 = keyChain.createIdentity(identity2));
-  
+
   shared_ptr<Interest> commandInterest3 = make_shared<Interest>("/TestCommandInterest/Validation/Command3");
   generator.generateWithIdentity(*commandInterest3, identity2);
   validator.validate(*commandInterest3,
   		     bind(&CommandInterestFixture::validated, this, _1),
   		     bind(&CommandInterestFixture::validationFailed, this, _1, _2));
-  
+
   BOOST_CHECK_EQUAL(m_validity, false);
 
   //Test another unauthorized command
@@ -124,7 +129,7 @@
   validator.validate(*commandInterest4,
   		     bind(&CommandInterestFixture::validated, this, _1),
   		     bind(&CommandInterestFixture::validationFailed, this, _1, _2));
-  
+
   BOOST_CHECK_EQUAL(m_validity, false);
 
   BOOST_CHECK_NO_THROW(keyChain.deleteIdentity(identity));
diff --git a/tests/security/test-validator.cpp b/tests/security/test-validator.cpp
index bf55bda..c909c06 100644
--- a/tests/security/test-validator.cpp
+++ b/tests/security/test-validator.cpp
@@ -31,7 +31,9 @@
 {
   KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
 
-  Name identity("/TestValidator/Null/" + boost::lexical_cast<std::string>(time::now()));
+  Name identity("/TestValidator/Null");
+  identity.appendVersion();
+
   BOOST_REQUIRE_NO_THROW(keyChain.createIdentity(identity));
 
   Name dataName = identity;
diff --git a/tests/test-data.cpp b/tests/test-data.cpp
index b5b2083..19241b5 100644
--- a/tests/test-data.cpp
+++ b/tests/test-data.cpp
@@ -118,7 +118,7 @@
 
   BOOST_REQUIRE_EQUAL(d.getName().toUri(), "/local/ndn/prefix");
   BOOST_REQUIRE_EQUAL(d.getContentType(), static_cast<uint32_t>(MetaInfo::TYPE_DEFAULT));
-  BOOST_REQUIRE_EQUAL(d.getFreshnessPeriod(), 10000);
+  BOOST_REQUIRE_EQUAL(d.getFreshnessPeriod(), time::seconds(10));
 
   BOOST_REQUIRE_EQUAL(std::string(reinterpret_cast<const char*>(d.getContent().value()), d.getContent().value_size()), "SUCCESS!");
 
@@ -143,7 +143,7 @@
   
   ndn::Data d(ndn::Name("/local/ndn/prefix"));
   d.setContentType(MetaInfo::TYPE_DEFAULT);
-  d.setFreshnessPeriod(10000);
+  d.setFreshnessPeriod(time::seconds(10));
   
   d.setContent(Content1, sizeof(Content1));
 
@@ -201,7 +201,7 @@
 {
   MetaInfo meta;
   meta.setType(MetaInfo::TYPE_DEFAULT);
-  meta.setFreshnessPeriod(10000);
+  meta.setFreshnessPeriod(time::seconds(10));
 
   BOOST_REQUIRE_NO_THROW(meta.wireEncode());
   BOOST_REQUIRE_EQUAL_COLLECTIONS(MetaInfo1, MetaInfo1+sizeof(MetaInfo1),
@@ -222,17 +222,17 @@
 {
   MetaInfo meta(Block(MetaInfo1, sizeof(MetaInfo1)));
   BOOST_CHECK_EQUAL(meta.getType(), static_cast<uint32_t>(MetaInfo::TYPE_DEFAULT));
-  BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), 10000);
+  BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), time::seconds(10));
   BOOST_CHECK_EQUAL(meta.getFinalBlockId(), name::Component());
 
   meta.wireDecode(Block(MetaInfo2, sizeof(MetaInfo2)));
   BOOST_CHECK_EQUAL(meta.getType(), static_cast<uint32_t>(MetaInfo::TYPE_DEFAULT));
-  BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), 10000);
+  BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), time::seconds(10));
   BOOST_CHECK_EQUAL(meta.getFinalBlockId(), name::Component("hello,world!"));
 
   meta.wireDecode(Block(MetaInfo3, sizeof(MetaInfo3)));
   BOOST_CHECK_EQUAL(meta.getType(), static_cast<uint32_t>(MetaInfo::TYPE_LINK));
-  BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), 10000);
+  BOOST_CHECK_EQUAL(meta.getFreshnessPeriod(), time::seconds(10));
   BOOST_CHECK_EQUAL(meta.getFinalBlockId(), name::Component("hello,world!"));
 }
 
diff --git a/tests/test-faces.cpp b/tests/test-faces.cpp
deleted file mode 100644
index 0205cb1..0000000
--- a/tests/test-faces.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * See COPYING for copyright and distribution information.
- */
-
-#include <boost/test/unit_test.hpp>
-#include "face.hpp"
-#include "util/scheduler.hpp"
-
-using namespace std;
-namespace ndn {
-
-BOOST_AUTO_TEST_SUITE(TestFaces)
-
-struct FacesFixture
-{
-  FacesFixture()
-    : dataCount(0)
-    , timeoutCount(0)
-    , regPrefixId(0)
-    , inInterestCount(0)
-    , inInterestCount2(0)
-    , regFailedCount(0)
-  {
-  }
-  
-  void
-  onData()
-  {
-    ++dataCount;
-  }
-
-  void
-  onTimeout()
-  {
-    ++timeoutCount;
-  }
-
-  void
-  onInterest(Face& face)
-  {
-    ++inInterestCount;
-
-    face.unsetInterestFilter(regPrefixId);
-  }
-
-  void
-  onInterest2(Face& face)
-  {
-    ++inInterestCount2;
-
-    face.unsetInterestFilter(regPrefixId2);
-  }
-
-  void
-  onRegFailed()
-  {
-    ++regFailedCount;
-  }
-
-  void
-  expressInterest(Face& face, const Name& name)
-  {
-    Interest i(name);
-    i.setInterestLifetime(50);
-    face.expressInterest(i,
-                         bind(&FacesFixture::onData, this),
-                         bind(&FacesFixture::onTimeout, this));
-  }
-
-  void
-  terminate(Face& face)
-  {
-    face.shutdown();
-  }
-
-  uint32_t dataCount;
-  uint32_t timeoutCount;
-
-  const RegisteredPrefixId* regPrefixId;
-  const RegisteredPrefixId* regPrefixId2;
-  uint32_t inInterestCount;
-  uint32_t inInterestCount2;
-  uint32_t regFailedCount;
-};
-
-BOOST_FIXTURE_TEST_CASE (Unix, FacesFixture)
-{
-  Face face;
-
-  face.expressInterest(Interest("/%C1.M.S.localhost/%C1.M.SRV/ndnd/KEY", 1000),
-                       ptr_lib::bind(&FacesFixture::onData, this),
-                       ptr_lib::bind(&FacesFixture::onTimeout, this));
-
-  BOOST_REQUIRE_NO_THROW(face.processEvents());
-
-  BOOST_CHECK_EQUAL(dataCount, 1);
-  BOOST_CHECK_EQUAL(timeoutCount, 0);
-
-  face.expressInterest(Interest("/localhost/non-existing/data/should/not/exist/anywhere", 50),
-                       ptr_lib::bind(&FacesFixture::onData, this),
-                       ptr_lib::bind(&FacesFixture::onTimeout, this));
-  
-  BOOST_REQUIRE_NO_THROW(face.processEvents());
-
-  BOOST_CHECK_EQUAL(dataCount, 1);
-  BOOST_CHECK_EQUAL(timeoutCount, 1);
-}
-
-BOOST_FIXTURE_TEST_CASE (Tcp, FacesFixture)
-{
-  Face face("localhost");
-
-  face.expressInterest(Interest("/%C1.M.S.localhost/%C1.M.SRV/ndnd/KEY", 1000),
-                       bind(&FacesFixture::onData, this),
-                       bind(&FacesFixture::onTimeout, this));
-
-  BOOST_REQUIRE_NO_THROW(face.processEvents());
-
-  BOOST_CHECK_EQUAL(dataCount, 1);
-  BOOST_CHECK_EQUAL(timeoutCount, 0);
-
-  face.expressInterest(Interest("/localhost/non-existing/data/should/not/exist/anywhere", 50),
-                       bind(&FacesFixture::onData, this),
-                       bind(&FacesFixture::onTimeout, this));
-
-  BOOST_REQUIRE_NO_THROW(face.processEvents());
-
-  BOOST_CHECK_EQUAL(dataCount, 1);
-  BOOST_CHECK_EQUAL(timeoutCount, 1);
-}
-
-
-BOOST_FIXTURE_TEST_CASE (SetFilter, FacesFixture)
-{
-  Face face;
-  Face face2(face.ioService());
-  Scheduler scheduler(*face.ioService());
-  scheduler.scheduleEvent(time::seconds(0.3),
-                          bind(&FacesFixture::terminate, this, func_lib::ref(face)));
-  
-  regPrefixId = face.setInterestFilter("/Hello/World",
-                                       bind(&FacesFixture::onInterest, this, func_lib::ref(face)),
-                                       bind(&FacesFixture::onRegFailed, this));
-
-  scheduler.scheduleEvent(time::seconds(0.2),
-                          bind(&FacesFixture::expressInterest, this,
-                               func_lib::ref(face2), Name("/Hello/World/!")));
-  
-  BOOST_REQUIRE_NO_THROW(face.processEvents());
-
-  BOOST_CHECK_EQUAL(regFailedCount, 0);  
-  BOOST_CHECK_EQUAL(inInterestCount, 1);  
-  BOOST_CHECK_EQUAL(timeoutCount, 1);
-  BOOST_CHECK_EQUAL(dataCount, 0);
-}
-
-BOOST_FIXTURE_TEST_CASE (SetTwoFilters, FacesFixture)
-{
-  Face face;
-  Face face2(face.ioService());
-  Scheduler scheduler(*face.ioService());
-  scheduler.scheduleEvent(time::seconds(1),
-                          bind(&FacesFixture::terminate, this, func_lib::ref(face)));
-  
-  regPrefixId = face.setInterestFilter("/Hello/World",
-                                       bind(&FacesFixture::onInterest, this, func_lib::ref(face)),
-                                       bind(&FacesFixture::onRegFailed, this));
-  
-  regPrefixId2 = face.setInterestFilter("/Los/Angeles/Lakers",
-                                       bind(&FacesFixture::onInterest2, this, func_lib::ref(face)),
-                                       bind(&FacesFixture::onRegFailed, this));
-
-
-  scheduler.scheduleEvent(time::seconds(0.2),
-                          bind(&FacesFixture::expressInterest, this,
-                               func_lib::ref(face2), Name("/Hello/World/!")));
-  
-  BOOST_REQUIRE_NO_THROW(face.processEvents());
-
-  BOOST_CHECK_EQUAL(regFailedCount, 0);  
-  BOOST_CHECK_EQUAL(inInterestCount, 1);  
-  BOOST_CHECK_EQUAL(inInterestCount2, 0);  
-  BOOST_CHECK_EQUAL(timeoutCount, 1);
-  BOOST_CHECK_EQUAL(dataCount, 0);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace ndn
diff --git a/tests/test-interest.cpp b/tests/test-interest.cpp
index 0c2db34..eca8066 100644
--- a/tests/test-interest.cpp
+++ b/tests/test-interest.cpp
@@ -63,7 +63,7 @@
 
   BOOST_REQUIRE_EQUAL(i.getName().toUri(), "/local/ndn/prefix");
   BOOST_REQUIRE_EQUAL(i.getScope(), 1);
-  BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), 1000);
+  BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), time::milliseconds(1000));
   BOOST_REQUIRE_EQUAL(i.getMinSuffixComponents(), 1);
   BOOST_REQUIRE_EQUAL(i.getMaxSuffixComponents(), 1);
   BOOST_REQUIRE_EQUAL(i.getChildSelector(), 1);
@@ -83,7 +83,7 @@
 
   BOOST_REQUIRE_EQUAL(i.getName().toUri(), "/local/ndn/prefix");
   BOOST_REQUIRE_EQUAL(i.getScope(), 1);
-  BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), 1000);
+  BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), time::milliseconds(1000));
   BOOST_REQUIRE_EQUAL(i.getMinSuffixComponents(), 1);
   BOOST_REQUIRE_EQUAL(i.getMaxSuffixComponents(), 1);
   BOOST_REQUIRE_EQUAL(i.getChildSelector(), 1);
@@ -96,7 +96,7 @@
 {
   ndn::Interest i(ndn::Name("/local/ndn/prefix"));
   i.setScope(1);
-  i.setInterestLifetime(1000);
+  i.setInterestLifetime(time::milliseconds(1000));
   i.setMinSuffixComponents(1);
   i.setMaxSuffixComponents(1);
   i.setChildSelector(1);
diff --git a/tests/util/test-io.cpp b/tests/util/test-io.cpp
index acbdc38..1e8b0bd 100644
--- a/tests/util/test-io.cpp
+++ b/tests/util/test-io.cpp
@@ -16,7 +16,9 @@
 {
   KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keychain;
 
-  Name identity("/TestIO/Basic/" + boost::lexical_cast<std::string>(time::now()));
+  Name identity("/TestIO/Basic");
+  identity.appendVersion();
+
   Name certName;
   BOOST_REQUIRE_NO_THROW(certName = keychain.createIdentity(identity));
   shared_ptr<IdentityCertificate> idCert;
diff --git a/tests/util/test-scheduler.cpp b/tests/util/test-scheduler.cpp
index 957ad98..66417da 100644
--- a/tests/util/test-scheduler.cpp
+++ b/tests/util/test-scheduler.cpp
@@ -21,7 +21,7 @@
     , count4(0)
   {
   }
-    
+
   void
   event1()
   {
@@ -47,7 +47,7 @@
   {
     ++count4;
   }
-  
+
   int count1;
   int count2;
   int count3;
@@ -56,22 +56,22 @@
 
 BOOST_FIXTURE_TEST_CASE(Events, SchedulerFixture)
 {
-  boost::asio::io_service io; 
+  boost::asio::io_service io;
 
   Scheduler scheduler(io);
-  scheduler.scheduleEvent(time::seconds(0.5), bind(&SchedulerFixture::event1, this));
-  
-  EventId i = scheduler.scheduleEvent(time::seconds(1.0), bind(&SchedulerFixture::event2, this));
+  scheduler.scheduleEvent(time::milliseconds(500), bind(&SchedulerFixture::event1, this));
+
+  EventId i = scheduler.scheduleEvent(time::seconds(1), bind(&SchedulerFixture::event2, this));
   scheduler.cancelEvent(i);
 
-  scheduler.scheduleEvent(time::seconds(0.25), bind(&SchedulerFixture::event3, this));
+  scheduler.scheduleEvent(time::milliseconds(250), bind(&SchedulerFixture::event3, this));
 
-  i = scheduler.scheduleEvent(time::seconds(0.05), bind(&SchedulerFixture::event2, this));
+  i = scheduler.scheduleEvent(time::milliseconds(50), bind(&SchedulerFixture::event2, this));
   scheduler.cancelEvent(i);
 
-  i = scheduler.schedulePeriodicEvent(time::seconds(1.5), time::seconds(0.5), bind(&SchedulerFixture::event4, this));
+  i = scheduler.schedulePeriodicEvent(time::milliseconds(1500), time::milliseconds(500), bind(&SchedulerFixture::event4, this));
   scheduler.scheduleEvent(time::seconds(4), bind(&Scheduler::cancelEvent, &scheduler, i));
-  
+
   io.run();
 
   BOOST_CHECK_EQUAL(count1, 1);
@@ -82,9 +82,9 @@
 
 BOOST_AUTO_TEST_CASE(CancelEmptyEvent)
 {
-  boost::asio::io_service io; 
+  boost::asio::io_service io;
   Scheduler scheduler(io);
-  
+
   EventId i;
   scheduler.cancelEvent(i);
 }
@@ -109,7 +109,7 @@
 
 BOOST_FIXTURE_TEST_CASE(SelfCancel, SelfCancelFixture)
 {
-  m_selfEventId = m_scheduler.scheduleEvent(time::seconds(0.1),
+  m_selfEventId = m_scheduler.scheduleEvent(time::milliseconds(100),
                                             bind(&SelfCancelFixture::cancelSelf, this));
 
   BOOST_REQUIRE_NO_THROW(m_io.run());
@@ -126,8 +126,8 @@
   void
   reschedule()
   {
-    EventId eventId = m_scheduler.scheduleEvent(time::seconds(0.1),
-                                                  bind(&SelfRescheduleFixture::reschedule, this));
+    EventId eventId = m_scheduler.scheduleEvent(time::milliseconds(100),
+                                                bind(&SelfRescheduleFixture::reschedule, this));
     m_scheduler.cancelEvent(m_selfEventId);
     m_selfEventId = eventId;
 
@@ -141,11 +141,11 @@
   reschedule2()
   {
     m_scheduler.cancelEvent(m_selfEventId);
-    
-    
+
+
     if(m_count < 5)
       {
-        m_selfEventId = m_scheduler.scheduleEvent(time::seconds(0.1),
+        m_selfEventId = m_scheduler.scheduleEvent(time::milliseconds(100),
                                                   bind(&SelfRescheduleFixture::reschedule2, this));
         m_count++;
       }
@@ -156,23 +156,23 @@
   {
     m_count++;
   }
-  
+
   void
   reschedule3()
   {
     m_scheduler.cancelEvent(m_selfEventId);
-    
-    m_scheduler.scheduleEvent(time::seconds(0.1),
+
+    m_scheduler.scheduleEvent(time::milliseconds(100),
                               bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::seconds(0.1),
+    m_scheduler.scheduleEvent(time::milliseconds(100),
                               bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::seconds(0.1),
+    m_scheduler.scheduleEvent(time::milliseconds(100),
                               bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::seconds(0.1),
+    m_scheduler.scheduleEvent(time::milliseconds(100),
                               bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::seconds(0.1),
+    m_scheduler.scheduleEvent(time::milliseconds(100),
                               bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::seconds(0.1),
+    m_scheduler.scheduleEvent(time::milliseconds(100),
                               bind(&SelfRescheduleFixture::doNothing, this));
   }
 
@@ -180,7 +180,7 @@
   Scheduler m_scheduler;
   EventId m_selfEventId;
   int m_count;
-  
+
 };
 
 BOOST_FIXTURE_TEST_CASE(Reschedule, SelfRescheduleFixture)
diff --git a/tests/util/test-time.cpp b/tests/util/test-time.cpp
index be4cc77..6351bb1 100644
--- a/tests/util/test-time.cpp
+++ b/tests/util/test-time.cpp
@@ -11,15 +11,27 @@
 
 BOOST_AUTO_TEST_SUITE(TestTime)
 
-BOOST_AUTO_TEST_CASE (Simple)
+BOOST_AUTO_TEST_CASE (SystemClock)
 {
-  MillisecondsSince1970 value = getNowMilliseconds();
-  BOOST_CHECK_GT(value, 1390966967032);
+  time::system_clock::TimePoint value = time::system_clock::now();
+  time::system_clock::TimePoint referenceTime =
+    time::fromUnixTimestamp(time::milliseconds(1390966967032));
 
-  BOOST_CHECK_EQUAL(toIsoString(1390966967032), "20140129T034247.032000");
-  BOOST_CHECK_EQUAL(fromIsoString("20140129T034247.032000"), 1390966967032);
+  BOOST_CHECK_GT(value, referenceTime);
 
-  BOOST_CHECK_EQUAL(fromIsoString("20140129T034247.032000Z"), 1390966967032);
+  BOOST_CHECK_EQUAL(time::toIsoString(referenceTime), "20140129T034247.032000");
+  BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000"), referenceTime);
+
+  BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000Z"), referenceTime);
+}
+
+BOOST_AUTO_TEST_CASE (SteadyClock)
+{
+  time::steady_clock::TimePoint oldValue = time::steady_clock::now();
+  usleep(100);
+  time::steady_clock::TimePoint newValue = time::steady_clock::now();
+
+  BOOST_CHECK_GT(newValue, oldValue);
 }
 
 BOOST_AUTO_TEST_SUITE_END()