aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/grpc/common/time_point.h
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
committerqrort <qrort@yandex-team.com>2022-11-30 23:47:12 +0300
commit22f8ae0e3f5d68b92aecccdf96c1d841a0334311 (patch)
treebffa27765faf54126ad44bcafa89fadecb7a73d7 /library/cpp/grpc/common/time_point.h
parent332b99e2173f0425444abb759eebcb2fafaa9209 (diff)
downloadydb-22f8ae0e3f5d68b92aecccdf96c1d841a0334311.tar.gz
validate canons without yatest_common
Diffstat (limited to 'library/cpp/grpc/common/time_point.h')
-rw-r--r--library/cpp/grpc/common/time_point.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/library/cpp/grpc/common/time_point.h b/library/cpp/grpc/common/time_point.h
new file mode 100644
index 0000000000..c2b8126297
--- /dev/null
+++ b/library/cpp/grpc/common/time_point.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <contrib/libs/grpc/include/grpcpp/support/time.h>
+
+#include <util/datetime/base.h>
+
+#include <chrono>
+
+namespace grpc {
+// Specialization of TimePoint for TInstant
+template <>
+class TimePoint<TInstant> : public TimePoint<std::chrono::system_clock::time_point> {
+ using TChronoDuration = std::chrono::duration<TDuration::TValue, std::micro>;
+
+public:
+ TimePoint(const TInstant& time)
+ : TimePoint<std::chrono::system_clock::time_point>(
+ std::chrono::system_clock::time_point(
+ std::chrono::duration_cast<std::chrono::system_clock::duration>(
+ TChronoDuration(time.GetValue())))) {
+ }
+};
+} // namespace grpc