aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAlexander Gagarin <unientity@gmail.com>2019-06-13 12:17:10 +0500
committerWenzel Jakob <wenzel.jakob@epfl.ch>2019-06-13 09:17:10 +0200
commitb3bf248eec9cad8260753c982e1ae6cb72fff470 (patch)
treeaeae994c5a31f3231b61d494f8d2f4a0d1c89882 /include
parented39c50458738794a77bd2a43a3564aaead0f191 (diff)
downloadplatform_external_python_pybind11-b3bf248eec9cad8260753c982e1ae6cb72fff470.tar.gz
platform_external_python_pybind11-b3bf248eec9cad8260753c982e1ae6cb72fff470.tar.bz2
platform_external_python_pybind11-b3bf248eec9cad8260753c982e1ae6cb72fff470.zip
Fix casting of time points with non-system-clock duration with VS (#1748)
* Fix casting of time points with non-system-clock duration on Windows Add explicit `time_point_cast` to time point with duration of system clock. Fixes Visual Studio compile error. * Add test case for custom time points casting
Diffstat (limited to 'include')
-rw-r--r--include/pybind11/chrono.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/pybind11/chrono.h b/include/pybind11/chrono.h
index 95ada76..2ace232 100644
--- a/include/pybind11/chrono.h
+++ b/include/pybind11/chrono.h
@@ -128,7 +128,7 @@ public:
// Lazy initialise the PyDateTime import
if (!PyDateTimeAPI) { PyDateTime_IMPORT; }
- std::time_t tt = system_clock::to_time_t(src);
+ std::time_t tt = system_clock::to_time_t(time_point_cast<system_clock::duration>(src));
// this function uses static memory so it's best to copy it out asap just in case
// otherwise other code that is using localtime may break this (not just python code)
std::tm localtime = *std::localtime(&tt);