summaryrefslogtreecommitdiff
path: root/boost/interprocess/sync/posix/ptime_to_timespec.hpp
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-10-30 19:57:26 (GMT)
committerAnas Nashif <anas.nashif@intel.com>2012-10-30 19:57:26 (GMT)
commit1a78a62555be32868418fe52f8e330c9d0f95d5a (patch)
treed3765a80e7d3b9640ec2e930743630cd6b9fce2b /boost/interprocess/sync/posix/ptime_to_timespec.hpp
downloadboost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip
boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz
boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'boost/interprocess/sync/posix/ptime_to_timespec.hpp')
-rw-r--r--boost/interprocess/sync/posix/ptime_to_timespec.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/boost/interprocess/sync/posix/ptime_to_timespec.hpp b/boost/interprocess/sync/posix/ptime_to_timespec.hpp
new file mode 100644
index 0000000..7d78735
--- /dev/null
+++ b/boost/interprocess/sync/posix/ptime_to_timespec.hpp
@@ -0,0 +1,38 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2005-2011. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/interprocess for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP
+#define BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP
+
+#include <boost/interprocess/detail/posix_time_types_wrk.hpp>
+
+namespace boost {
+
+namespace interprocess {
+
+namespace ipcdetail {
+
+inline timespec ptime_to_timespec (const boost::posix_time::ptime &tm)
+{
+ const boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
+ boost::posix_time::time_duration duration (tm - epoch);
+ timespec ts;
+ ts.tv_sec = duration.total_seconds();
+ ts.tv_nsec = duration.total_nanoseconds() % 1000000000;
+ return ts;
+}
+
+} //namespace ipcdetail {
+
+} //namespace interprocess {
+
+} //namespace boost {
+
+#endif //ifndef BOOST_INTERPROCESS_DETAIL_PTIME_TO_TIMESPEC_HPP