Merge branch 'master' of github.com:grpc/grpc into the-purge-2

Conflicts:
	src/cpp/client/channel.cc
	vsprojects/vs2010/grpc++.vcxproj
	vsprojects/vs2013/grpc++.vcxproj.filters
diff --git a/BUILD b/BUILD
index 2a93161..e2860fb 100644
--- a/BUILD
+++ b/BUILD
@@ -579,7 +579,6 @@
     "src/cpp/client/channel.h",
     "src/cpp/proto/proto_utils.h",
     "src/cpp/server/thread_pool.h",
-    "src/cpp/util/time.h",
     "src/cpp/client/secure_credentials.cc",
     "src/cpp/server/secure_server_credentials.cc",
     "src/cpp/client/channel.cc",
@@ -640,6 +639,7 @@
     "include/grpc++/status_code_enum.h",
     "include/grpc++/stream.h",
     "include/grpc++/thread_pool_interface.h",
+    "include/grpc++/time.h",
   ],
   includes = [
     "include",
@@ -659,7 +659,6 @@
     "src/cpp/client/channel.h",
     "src/cpp/proto/proto_utils.h",
     "src/cpp/server/thread_pool.h",
-    "src/cpp/util/time.h",
     "src/cpp/client/channel.cc",
     "src/cpp/client/channel_arguments.cc",
     "src/cpp/client/client_context.cc",
@@ -718,6 +717,7 @@
     "include/grpc++/status_code_enum.h",
     "include/grpc++/stream.h",
     "include/grpc++/thread_pool_interface.h",
+    "include/grpc++/time.h",
   ],
   includes = [
     "include",
diff --git a/Makefile b/Makefile
index 3e7930b..f30624f 100644
--- a/Makefile
+++ b/Makefile
@@ -3873,6 +3873,7 @@
     include/grpc++/status_code_enum.h \
     include/grpc++/stream.h \
     include/grpc++/thread_pool_interface.h \
+    include/grpc++/time.h \
 
 LIBGRPC++_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_SRC))))
 
@@ -4136,6 +4137,7 @@
     include/grpc++/status_code_enum.h \
     include/grpc++/stream.h \
     include/grpc++/thread_pool_interface.h \
+    include/grpc++/time.h \
 
 LIBGRPC++_UNSECURE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_UNSECURE_SRC))))
 
diff --git a/build.json b/build.json
index 8838d3a..9574df5 100644
--- a/build.json
+++ b/build.json
@@ -46,13 +46,13 @@
         "include/grpc++/status.h",
         "include/grpc++/status_code_enum.h",
         "include/grpc++/stream.h",
-        "include/grpc++/thread_pool_interface.h"
+        "include/grpc++/thread_pool_interface.h",
+        "include/grpc++/time.h"
       ],
       "headers": [
         "src/cpp/client/channel.h",
         "src/cpp/proto/proto_utils.h",
-        "src/cpp/server/thread_pool.h",
-        "src/cpp/util/time.h"
+        "src/cpp/server/thread_pool.h"
       ],
       "src": [
         "src/cpp/client/channel.cc",
diff --git a/examples/pubsub/main.cc b/examples/pubsub/main.cc
index 8f8eefa..cf0f21e 100644
--- a/examples/pubsub/main.cc
+++ b/examples/pubsub/main.cc
@@ -31,7 +31,6 @@
  *
  */
 
-#include <chrono>
 #include <fstream>
 #include <memory>
 #include <sstream>
diff --git a/include/grpc++/client_context.h b/include/grpc++/client_context.h
index 4e7f5a7..19630c9 100644
--- a/include/grpc++/client_context.h
+++ b/include/grpc++/client_context.h
@@ -34,15 +34,13 @@
 #ifndef GRPCXX_CLIENT_CONTEXT_H
 #define GRPCXX_CLIENT_CONTEXT_H
 
-#include <chrono>
 #include <map>
 #include <string>
 
 #include <grpc/support/log.h>
 #include <grpc/support/time.h>
 #include <grpc++/config.h>
-
-using std::chrono::system_clock;
+#include <grpc++/time.h>
 
 struct grpc_call;
 struct grpc_completion_queue;
@@ -87,8 +85,19 @@
     return trailing_metadata_;
   }
 
-  void set_absolute_deadline(const system_clock::time_point& deadline);
-  system_clock::time_point absolute_deadline();
+  template <typename T>
+  void set_deadline(const T& deadline) {
+    TimePoint<T> deadline_tp(deadline);
+    deadline_ = deadline_tp.raw_time();
+  }
+
+#ifndef GRPC_CXX0X_NO_CHRONO
+  std::chrono::system_clock::time_point deadline() {
+    return Timespec2Timepoint(deadline_);
+  }
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+  gpr_timespec raw_deadline() { return deadline_; }
 
   void set_authority(const grpc::string& authority) { authority_ = authority; }
 
@@ -125,14 +134,12 @@
   grpc_completion_queue* cq() { return cq_; }
   void set_cq(grpc_completion_queue* cq) { cq_ = cq; }
 
-  gpr_timespec RawDeadline() { return absolute_deadline_; }
-
   grpc::string authority() { return authority_; }
 
   bool initial_metadata_received_;
   grpc_call* call_;
   grpc_completion_queue* cq_;
-  gpr_timespec absolute_deadline_;
+  gpr_timespec deadline_;
   grpc::string authority_;
   std::multimap<grpc::string, grpc::string> send_initial_metadata_;
   std::multimap<grpc::string, grpc::string> recv_initial_metadata_;
diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h
index e6a8c6f..ba390c9 100644
--- a/include/grpc++/completion_queue.h
+++ b/include/grpc++/completion_queue.h
@@ -34,9 +34,9 @@
 #ifndef GRPCXX_COMPLETION_QUEUE_H
 #define GRPCXX_COMPLETION_QUEUE_H
 
-#include <chrono>
-#include <grpc++/impl/client_unary_call.h>
 #include <grpc/support/time.h>
+#include <grpc++/impl/client_unary_call.h>
+#include <grpc++/time.h>
 
 struct grpc_completion_queue;
 
@@ -82,10 +82,13 @@
 
   // Nonblocking (until deadline) read from queue.
   // Cannot rely on result of tag or ok if return is TIMEOUT
-  NextStatus AsyncNext(void** tag, bool* ok,
-                       std::chrono::system_clock::time_point deadline);
+  template<typename T>
+  NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) {
+    TimePoint<T> deadline_tp(deadline);
+    return AsyncNextInternal(tag, ok, deadline_tp.raw_time());
+  }
 
-  // Blocking (until deadline) read from queue.
+  // Blocking read from queue.
   // Returns false if the queue is ready for destruction, true if event
 
   bool Next(void** tag, bool* ok) {
diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h
index 2ac3eec..a193bba 100644
--- a/include/grpc++/credentials.h
+++ b/include/grpc++/credentials.h
@@ -34,7 +34,6 @@
 #ifndef GRPCXX_CREDENTIALS_H
 #define GRPCXX_CREDENTIALS_H
 
-#include <chrono>
 #include <memory>
 
 #include <grpc++/config.h>
@@ -98,20 +97,20 @@
 // Builds service account credentials.
 // json_key is the JSON key string containing the client's private key.
 // scope is a space-delimited list of the requested permissions.
-// token_lifetime is the lifetime of each token acquired through this service
-// account credentials. It should be positive and should not exceed
-// grpc_max_auth_token_lifetime or will be cropped to this value.
+// token_lifetime_seconds is the lifetime in seconds of each token acquired
+// through this service account credentials. It should be positive and should
+// not exceed grpc_max_auth_token_lifetime or will be cropped to this value.
 std::unique_ptr<Credentials> ServiceAccountCredentials(
     const grpc::string& json_key, const grpc::string& scope,
-    std::chrono::seconds token_lifetime);
+    long token_lifetime_seconds);
 
 // Builds JWT credentials.
 // json_key is the JSON key string containing the client's private key.
-// token_lifetime is the lifetime of each Json Web Token (JWT) created with
-// this credentials.  It should not exceed grpc_max_auth_token_lifetime or
-// will be cropped to this value.
+// token_lifetime_seconds is the lifetime in seconds of each Json Web Token
+// (JWT) created with this credentials. It should not exceed
+// grpc_max_auth_token_lifetime or will be cropped to this value.
 std::unique_ptr<Credentials> JWTCredentials(
-    const grpc::string& json_key, std::chrono::seconds token_lifetime);
+    const grpc::string& json_key, long token_lifetime_seconds);
 
 // Builds refresh token credentials.
 // json_refresh_token is the JSON string containing the refresh token along
diff --git a/include/grpc++/server_context.h b/include/grpc++/server_context.h
index 9e3b80c..a62babd 100644
--- a/include/grpc++/server_context.h
+++ b/include/grpc++/server_context.h
@@ -34,10 +34,11 @@
 #ifndef GRPCXX_SERVER_CONTEXT_H
 #define GRPCXX_SERVER_CONTEXT_H
 
-#include <chrono>
 #include <map>
 
+#include <grpc/support/time.h>
 #include <grpc++/config.h>
+#include <grpc++/time.h>
 
 struct gpr_timespec;
 struct grpc_metadata;
@@ -71,9 +72,13 @@
   ServerContext();  // for async calls
   ~ServerContext();
 
-  std::chrono::system_clock::time_point absolute_deadline() {
-    return deadline_;
+#ifndef GRPC_CXX0X_NO_CHRONO
+  std::chrono::system_clock::time_point deadline() {
+    return Timespec2Timepoint(deadline_);
   }
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+  gpr_timespec raw_deadline() { return deadline_; }
 
   void AddInitialMetadata(const grpc::string& key, const grpc::string& value);
   void AddTrailingMetadata(const grpc::string& key, const grpc::string& value);
@@ -110,7 +115,7 @@
 
   CompletionOp* completion_op_;
 
-  std::chrono::system_clock::time_point deadline_;
+  gpr_timespec deadline_;
   grpc_call* call_;
   CompletionQueue* cq_;
   bool sent_initial_metadata_;
diff --git a/include/grpc++/time.h b/include/grpc++/time.h
new file mode 100644
index 0000000..1fc4ad7
--- /dev/null
+++ b/include/grpc++/time.h
@@ -0,0 +1,106 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_INTERNAL_CPP_UTIL_TIME_H
+#define GRPC_INTERNAL_CPP_UTIL_TIME_H
+
+#include <grpc++/config.h>
+
+namespace grpc {
+
+/* If you are trying to use CompletionQueue::AsyncNext with a time class that
+   isn't either gpr_timespec or std::chrono::system_clock::time_point, you
+   will most likely be looking at that comment as your compiler will have
+   fired an error below. In order to fix that issue, you have two potential
+   solutions:
+
+     1. Use gpr_timespec or std::chrono::system_clock::time_point instead
+     2. Specialize the TimePoint class with whichever time class that you
+        want to use here. See below for two examples of how to do that.
+ */
+
+template <typename T>
+class TimePoint {
+ public:
+  TimePoint(const T& time) {
+    you_need_a_specialization_of_TimePoint();
+  }
+  gpr_timespec raw_time() {
+    gpr_timespec t;
+    return t;
+  }
+ private:
+  void you_need_a_specialization_of_TimePoint();
+};
+
+template<>
+class TimePoint<gpr_timespec> {
+ public:
+  TimePoint(const gpr_timespec& time) : time_(time) { }
+  gpr_timespec raw_time() { return time_; }
+ private:
+  gpr_timespec time_;
+};
+
+}  // namespace grpc
+
+#ifndef GRPC_CXX0X_NO_CHRONO
+
+#include <chrono>
+
+#include <grpc/support/time.h>
+
+namespace grpc {
+
+// from and to should be absolute time.
+void Timepoint2Timespec(const std::chrono::system_clock::time_point& from,
+                        gpr_timespec* to);
+
+std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t);
+
+template <>
+class TimePoint<std::chrono::system_clock::time_point> {
+ public:
+  TimePoint(const std::chrono::system_clock::time_point& time) {
+	Timepoint2Timespec(time, &time_);
+  }
+  gpr_timespec raw_time() const { return time_; }
+ private:
+  gpr_timespec time_;
+};
+
+}  // namespace grpc
+
+#endif  // !GRPC_CXX0X_NO_CHRONO
+
+#endif  // GRPC_INTERNAL_CPP_UTIL_TIME_H
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc
index 478f223..ba88822 100644
--- a/src/cpp/client/channel.cc
+++ b/src/cpp/client/channel.cc
@@ -33,7 +33,6 @@
 
 #include "src/cpp/client/channel.h"
 
-#include <chrono>
 #include <memory>
 
 #include <grpc/grpc.h>
@@ -65,12 +64,12 @@
       method.channel_tag()
           ? grpc_channel_create_registered_call(c_channel_, cq->cq(),
                                                 method.channel_tag(),
-                                                context->RawDeadline())
+                                                context->raw_deadline())
           : grpc_channel_create_call(c_channel_, cq->cq(), method.name(),
                                      context->authority().empty()
                                          ? target_.c_str()
                                          : context->authority().c_str(),
-                                     context->RawDeadline());
+                                     context->raw_deadline());
   GRPC_TIMER_MARK(CALL_CREATED, c_call);
   context->set_call(c_call);
   return Call(c_call, this, cq);
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index de9f8c7..70c9cb4 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -34,9 +34,7 @@
 #include <grpc++/client_context.h>
 
 #include <grpc/grpc.h>
-#include "src/cpp/util/time.h"
-
-using std::chrono::system_clock;
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -44,7 +42,7 @@
     : initial_metadata_received_(false),
       call_(nullptr),
       cq_(nullptr),
-      absolute_deadline_(gpr_inf_future) {}
+      deadline_(gpr_inf_future) {}
 
 ClientContext::~ClientContext() {
   if (call_) {
@@ -64,15 +62,6 @@
   }
 }
 
-void ClientContext::set_absolute_deadline(
-    const system_clock::time_point& deadline) {
-  Timepoint2Timespec(deadline, &absolute_deadline_);
-}
-
-system_clock::time_point ClientContext::absolute_deadline() {
-  return Timespec2Timepoint(absolute_deadline_);
-}
-
 void ClientContext::AddMetadata(const grpc::string& meta_key,
                                 const grpc::string& meta_value) {
   send_initial_metadata_.insert(std::make_pair(meta_key, meta_value));
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index 0a73b2c..9e83ac8 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -81,27 +81,27 @@
 // Builds service account credentials.
 std::unique_ptr<Credentials> ServiceAccountCredentials(
     const grpc::string& json_key, const grpc::string& scope,
-    std::chrono::seconds token_lifetime) {
-  if (token_lifetime.count() <= 0) {
+    long token_lifetime) {
+  if (token_lifetime <= 0) {
     gpr_log(GPR_ERROR,
             "Trying to create ServiceAccountCredentials "
             "with non-positive lifetime");
     return WrapCredentials(nullptr);
   }
-  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime.count());
+  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime);
   return WrapCredentials(grpc_service_account_credentials_create(
       json_key.c_str(), scope.c_str(), lifetime));
 }
 
 // Builds JWT credentials.
 std::unique_ptr<Credentials> JWTCredentials(
-    const grpc::string& json_key, std::chrono::seconds token_lifetime) {
-  if (token_lifetime.count() <= 0) {
+    const grpc::string& json_key, long token_lifetime) {
+  if (token_lifetime <= 0) {
     gpr_log(GPR_ERROR,
             "Trying to create JWTCredentials with non-positive lifetime");
     return WrapCredentials(nullptr);
   }
-  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime.count());
+  gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime);
   return WrapCredentials(
       grpc_jwt_credentials_create(json_key.c_str(), lifetime));
 }
diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc
index cea2d24..3c37e91 100644
--- a/src/cpp/common/completion_queue.cc
+++ b/src/cpp/common/completion_queue.cc
@@ -36,7 +36,7 @@
 
 #include <grpc/grpc.h>
 #include <grpc/support/log.h>
-#include "src/cpp/util/time.h"
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -77,13 +77,6 @@
   }
 }
 
-CompletionQueue::NextStatus CompletionQueue::AsyncNext(
-    void** tag, bool* ok, std::chrono::system_clock::time_point deadline) {
-  gpr_timespec gpr_deadline;
-  Timepoint2Timespec(deadline, &gpr_deadline);
-  return AsyncNextInternal(tag, ok, gpr_deadline);
-}
-
 bool CompletionQueue::Pluck(CompletionQueueTag* tag) {
   std::unique_ptr<grpc_event, EventDeleter> ev;
 
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc
index b3cd1fd..1d39378 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -45,10 +45,10 @@
 #include <grpc++/server_context.h>
 #include <grpc++/server_credentials.h>
 #include <grpc++/thread_pool_interface.h>
+#include <grpc++/time.h>
 
 #include "src/core/profiling/timers.h"
 #include "src/cpp/proto/proto_utils.h"
-#include "src/cpp/util/time.h"
 
 namespace grpc {
 
@@ -353,7 +353,7 @@
     ServerContext* ctx = ctx_ ? ctx_ : generic_ctx_;
     GPR_ASSERT(ctx);
     if (*status) {
-      ctx->deadline_ = Timespec2Timepoint(call_details_.deadline);
+      ctx->deadline_ = call_details_.deadline;
       for (size_t i = 0; i < array_.count; i++) {
         ctx->client_metadata_.insert(std::make_pair(
             grpc::string(array_.metadata[i].key),
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index ffd6d30..6b5e41d 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -33,11 +33,11 @@
 
 #include <grpc++/server_context.h>
 
-#include <grpc++/impl/call.h>
-#include <grpc++/impl/sync.h>
 #include <grpc/grpc.h>
 #include <grpc/support/log.h>
-#include "src/cpp/util/time.h"
+#include <grpc++/impl/call.h>
+#include <grpc++/impl/sync.h>
+#include <grpc++/time.h>
 
 namespace grpc {
 
@@ -99,7 +99,7 @@
 ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
                              size_t metadata_count)
     : completion_op_(nullptr),
-      deadline_(Timespec2Timepoint(deadline)),
+      deadline_(deadline),
       call_(nullptr),
       cq_(nullptr),
       sent_initial_metadata_(false) {
diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc
index 059ea72..1fef2a5 100644
--- a/src/cpp/util/time.cc
+++ b/src/cpp/util/time.cc
@@ -31,9 +31,12 @@
  *
  */
 
-#include "src/cpp/util/time.h"
+#include <grpc++/config.h>
+
+#ifndef GRPC_CXX0X_NO_CHRONO
 
 #include <grpc/support/time.h>
+#include <grpc++/time.h>
 
 using std::chrono::duration_cast;
 using std::chrono::nanoseconds;
@@ -68,3 +71,5 @@
 }
 
 }  // namespace grpc
+
+#endif  // !GRPC_CXX0X_NO_CHRONO
diff --git a/src/cpp/util/time.h b/src/cpp/util/time.h
deleted file mode 100644
index 8b7fcf5..0000000
--- a/src/cpp/util/time.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *
- * Copyright 2015, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GRPC_INTERNAL_CPP_UTIL_TIME_H
-#define GRPC_INTERNAL_CPP_UTIL_TIME_H
-
-#include <chrono>
-
-#include <grpc/support/time.h>
-
-namespace grpc {
-
-// from and to should be absolute time.
-void Timepoint2Timespec(const std::chrono::system_clock::time_point& from,
-                        gpr_timespec* to);
-
-std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t);
-
-}  // namespace grpc
-
-#endif  // GRPC_INTERNAL_CPP_UTIL_TIME_H
diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc
index 24251f2..d7ea09a 100644
--- a/test/cpp/client/credentials_test.cc
+++ b/test/cpp/client/credentials_test.cc
@@ -47,7 +47,7 @@
 
 TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
   std::unique_ptr<Credentials> bad1 =
-      ServiceAccountCredentials("", "", std::chrono::seconds(1));
+      ServiceAccountCredentials("", "", 1);
   EXPECT_EQ(nullptr, bad1.get());
 }
 
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index dd294d9..c5d6840 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -31,13 +31,12 @@
  *
  */
 
-#include <chrono>
 #include <memory>
 
+#include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo_duplicate.grpc.pb.h"
 #include "test/cpp/util/echo.grpc.pb.h"
-#include "src/cpp/util/time.h"
 #include <grpc++/async_unary_call.h>
 #include <grpc++/channel_arguments.h>
 #include <grpc++/channel_interface.h>
@@ -50,7 +49,7 @@
 #include <grpc++/server_credentials.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
-#include "test/core/util/port.h"
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 2d3b405..07b5319 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -31,13 +31,12 @@
  *
  */
 
-#include <chrono>
 #include <thread>
 
+#include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo_duplicate.grpc.pb.h"
 #include "test/cpp/util/echo.grpc.pb.h"
-#include "src/cpp/util/time.h"
 #include "src/cpp/server/thread_pool.h"
 #include <grpc++/channel_arguments.h>
 #include <grpc++/channel_interface.h>
@@ -50,7 +49,7 @@
 #include <grpc++/server_credentials.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
-#include "test/core/util/port.h"
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>
@@ -72,8 +71,8 @@
                        EchoResponse* response) {
   if (request->has_param() && request->param().echo_deadline()) {
     gpr_timespec deadline = gpr_inf_future;
-    if (context->absolute_deadline() != system_clock::time_point::max()) {
-      Timepoint2Timespec(context->absolute_deadline(), &deadline);
+    if (context->deadline() != system_clock::time_point::max()) {
+      Timepoint2Timespec(context->deadline(), &deadline);
     }
     response->mutable_param()->set_request_deadline(deadline.tv_sec);
   }
@@ -245,7 +244,7 @@
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::microseconds(10);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(StatusCode::DEADLINE_EXCEEDED, s.code());
 }
@@ -260,7 +259,7 @@
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::hours(1);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(response.message(), request.message());
   EXPECT_TRUE(s.IsOk());
@@ -277,7 +276,7 @@
   ClientContext context;
   std::chrono::system_clock::time_point deadline =
       std::chrono::system_clock::now() + std::chrono::seconds(100);
-  context.set_absolute_deadline(deadline);
+  context.set_deadline(deadline);
   Status s = stub_->Echo(&context, request, &response);
   EXPECT_EQ(response.message(), request.message());
   EXPECT_TRUE(s.IsOk());
@@ -428,7 +427,7 @@
 // rpc and stream should fail on bad credentials.
 TEST_F(End2endTest, BadCredentials) {
   std::unique_ptr<Credentials> bad_creds =
-      ServiceAccountCredentials("", "", std::chrono::seconds(1));
+      ServiceAccountCredentials("", "", 1);
   EXPECT_EQ(nullptr, bad_creds.get());
   std::shared_ptr<ChannelInterface> channel =
       CreateChannel(server_address_.str(), bad_creds, ChannelArguments());
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index 584d4bc..ef3d0ad 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -31,11 +31,9 @@
  *
  */
 
-#include <chrono>
 #include <memory>
 
 #include "src/cpp/proto/proto_utils.h"
-#include "src/cpp/util/time.h"
 #include "test/core/util/port.h"
 #include "test/core/util/test_config.h"
 #include "test/cpp/util/echo.grpc.pb.h"
@@ -55,6 +53,7 @@
 #include <grpc++/slice.h>
 #include <grpc++/status.h>
 #include <grpc++/stream.h>
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 #include <grpc/grpc.h>
diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc
index b4d5b88..a1dea38 100644
--- a/test/cpp/interop/client_helper.cc
+++ b/test/cpp/interop/client_helper.cc
@@ -85,8 +85,9 @@
     std::unique_ptr<Credentials> creds;
     GPR_ASSERT(FLAGS_enable_ssl);
     grpc::string json_key = GetServiceAccountJsonKey();
+    std::chrono::seconds token_lifetime = std::chrono::hours(1);
     creds = ServiceAccountCredentials(json_key, FLAGS_oauth_scope,
-                                      std::chrono::hours(1));
+                                      token_lifetime.count());
     return CreateTestChannel(host_port, FLAGS_server_host_override,
                              FLAGS_enable_ssl, FLAGS_use_prod_roots, creds);
   } else if (test_case == "compute_engine_creds") {
@@ -99,7 +100,8 @@
     std::unique_ptr<Credentials> creds;
     GPR_ASSERT(FLAGS_enable_ssl);
     grpc::string json_key = GetServiceAccountJsonKey();
-    creds = JWTCredentials(json_key, std::chrono::hours(1));
+    std::chrono::seconds token_lifetime = std::chrono::hours(1);
+    creds = JWTCredentials(json_key, token_lifetime.count());
     return CreateTestChannel(host_port, FLAGS_server_host_override,
                              FLAGS_enable_ssl, FLAGS_use_prod_roots, creds);
   } else {
diff --git a/test/cpp/util/time_test.cc b/test/cpp/util/time_test.cc
index 4641fdb..a3cfb1c 100644
--- a/test/cpp/util/time_test.cc
+++ b/test/cpp/util/time_test.cc
@@ -31,11 +31,8 @@
  *
  */
 
-#include "src/cpp/util/time.h"
-
-#include <chrono>
-
 #include <grpc/support/time.h>
+#include <grpc++/time.h>
 #include <gtest/gtest.h>
 
 using std::chrono::duration_cast;
diff --git a/vsprojects/grpc++/grpc++.vcxproj b/vsprojects/grpc++/grpc++.vcxproj
index 38eca1a..50f3061 100644
--- a/vsprojects/grpc++/grpc++.vcxproj
+++ b/vsprojects/grpc++/grpc++.vcxproj
@@ -115,6 +115,7 @@
     <ClInclude Include="..\..\include\grpc++\status_code_enum.h" />
     <ClInclude Include="..\..\include\grpc++\stream.h" />
     <ClInclude Include="..\..\include\grpc++\thread_pool_interface.h" />
+    <ClInclude Include="..\..\include\grpc++\time.h" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cpp\client\secure_credentials.h" />
@@ -122,7 +123,6 @@
     <ClInclude Include="..\..\src\cpp\client\channel.h" />
     <ClInclude Include="..\..\src\cpp\proto\proto_utils.h" />
     <ClInclude Include="..\..\src\cpp\server\thread_pool.h" />
-    <ClInclude Include="..\..\src\cpp\util\time.h" />
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\src\cpp\client\secure_credentials.cc">
diff --git a/vsprojects/grpc++/grpc++.vcxproj.filters b/vsprojects/grpc++/grpc++.vcxproj.filters
index 6466a0f..698f1ce 100644
--- a/vsprojects/grpc++/grpc++.vcxproj.filters
+++ b/vsprojects/grpc++/grpc++.vcxproj.filters
@@ -177,6 +177,9 @@
     <ClInclude Include="..\..\include\grpc++\thread_pool_interface.h">
       <Filter>include\grpc++</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\include\grpc++\time.h">
+      <Filter>include\grpc++</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cpp\client\secure_credentials.h">
@@ -194,9 +197,6 @@
     <ClInclude Include="..\..\src\cpp\server\thread_pool.h">
       <Filter>src\cpp\server</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\cpp\util\time.h">
-      <Filter>src\cpp\util</Filter>
-    </ClInclude>
   </ItemGroup>
 
   <ItemGroup>