|
12 | 12 | #include <pybind11/chrono.h>
|
13 | 13 | #include <chrono>
|
14 | 14 |
|
| 15 | +struct different_resolutions { |
| 16 | + using time_point_h = std::chrono::time_point< |
| 17 | + std::chrono::system_clock, std::chrono::hours>; |
| 18 | + using time_point_m = std::chrono::time_point< |
| 19 | + std::chrono::system_clock, std::chrono::minutes>; |
| 20 | + using time_point_s = std::chrono::time_point< |
| 21 | + std::chrono::system_clock, std::chrono::seconds>; |
| 22 | + using time_point_ms = std::chrono::time_point< |
| 23 | + std::chrono::system_clock, std::chrono::milliseconds>; |
| 24 | + using time_point_us = std::chrono::time_point< |
| 25 | + std::chrono::system_clock, std::chrono::microseconds>; |
| 26 | + time_point_h timestamp_h; |
| 27 | + time_point_m timestamp_m; |
| 28 | + time_point_s timestamp_s; |
| 29 | + time_point_ms timestamp_ms; |
| 30 | + time_point_us timestamp_us; |
| 31 | +}; |
| 32 | + |
15 | 33 | TEST_SUBMODULE(chrono, m) {
|
16 | 34 | using system_time = std::chrono::system_clock::time_point;
|
17 | 35 | using steady_time = std::chrono::steady_clock::time_point;
|
@@ -53,4 +71,14 @@ TEST_SUBMODULE(chrono, m) {
|
53 | 71 | m.def("test_nano_timepoint", [](timestamp start, timespan delta) -> timestamp {
|
54 | 72 | return start + delta;
|
55 | 73 | });
|
| 74 | + |
| 75 | + // Test different resolutions |
| 76 | + py::class_<different_resolutions>(m, "different_resolutions") |
| 77 | + .def(py::init<>()) |
| 78 | + .def_readwrite("timestamp_h", &different_resolutions::timestamp_h) |
| 79 | + .def_readwrite("timestamp_m", &different_resolutions::timestamp_m) |
| 80 | + .def_readwrite("timestamp_s", &different_resolutions::timestamp_s) |
| 81 | + .def_readwrite("timestamp_ms", &different_resolutions::timestamp_ms) |
| 82 | + .def_readwrite("timestamp_us", &different_resolutions::timestamp_us) |
| 83 | + ; |
56 | 84 | }
|
0 commit comments