summaryrefslogtreecommitdiff
path: root/src/time
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-05-08 16:11:14 +0200
committerMax Kellermann <max@musicpd.org>2019-05-08 16:11:14 +0200
commitaf3ea97a429a0d910329dfda5b1b1a4107e5bb90 (patch)
tree9ddc06be648cdb24be4562ae10aba486f7f90993 /src/time
parent8beac03dc43199eb2120c3435db0c8e8ae993db3 (diff)
zeroconf/AvahiPoll: move TimevalToChrono() to time/Convert.cxx
Diffstat (limited to 'src/time')
-rw-r--r--src/time/Convert.cxx7
-rw-r--r--src/time/Convert.hxx4
2 files changed, 11 insertions, 0 deletions
diff --git a/src/time/Convert.cxx b/src/time/Convert.cxx
index fcb19dbe5..044cfd303 100644
--- a/src/time/Convert.cxx
+++ b/src/time/Convert.cxx
@@ -81,3 +81,10 @@ MakeTime(struct tm &tm) noexcept
{
return std::chrono::system_clock::from_time_t(mktime(&tm));
}
+
+std::chrono::steady_clock::duration
+ToSteadyClockDuration(const struct timeval &tv) noexcept
+{
+ return std::chrono::steady_clock::duration(std::chrono::seconds(tv.tv_sec)) +
+ std::chrono::steady_clock::duration(std::chrono::microseconds(tv.tv_usec));
+}
diff --git a/src/time/Convert.hxx b/src/time/Convert.hxx
index a84ecdf02..558bd2e37 100644
--- a/src/time/Convert.hxx
+++ b/src/time/Convert.hxx
@@ -67,4 +67,8 @@ gcc_pure
std::chrono::system_clock::time_point
MakeTime(struct tm &tm) noexcept;
+gcc_pure
+std::chrono::steady_clock::duration
+ToSteadyClockDuration(const struct timeval &tv) noexcept;
+
#endif