chrono.rst (12037:d28054ac6ec9) | chrono.rst (14299:2fbea9df56d2) |
---|---|
1Chrono 2====== 3 4When including the additional header file :file:`pybind11/chrono.h` conversions 5from C++11 chrono datatypes to python datetime objects are automatically enabled. 6This header also enables conversions of python floats (often from sources such 7as ``time.monotonic()``, ``time.perf_counter()`` and ``time.process_time()``) 8into durations. --- 45 unchanged lines hidden (view full) --- 54 greater than microseconds is lost by rounding towards zero. 55 56- ``std::chrono::[other_clocks]::time_point`` → ``datetime.timedelta`` 57 Any clock time that is not the system clock is converted to a time delta. 58 This timedelta measures the time from the clocks epoch to now. 59 60.. rubric:: Python to C++ 61 | 1Chrono 2====== 3 4When including the additional header file :file:`pybind11/chrono.h` conversions 5from C++11 chrono datatypes to python datetime objects are automatically enabled. 6This header also enables conversions of python floats (often from sources such 7as ``time.monotonic()``, ``time.perf_counter()`` and ``time.process_time()``) 8into durations. --- 45 unchanged lines hidden (view full) --- 54 greater than microseconds is lost by rounding towards zero. 55 56- ``std::chrono::[other_clocks]::time_point`` → ``datetime.timedelta`` 57 Any clock time that is not the system clock is converted to a time delta. 58 This timedelta measures the time from the clocks epoch to now. 59 60.. rubric:: Python to C++ 61 |
62- ``datetime.datetime`` → ``std::chrono::system_clock::time_point`` | 62- ``datetime.datetime`` or ``datetime.date`` or ``datetime.time`` → ``std::chrono::system_clock::time_point`` |
63 Date/time objects are converted into system clock timepoints. Any 64 timezone information is ignored and the type is treated as a naive 65 object. 66 67- ``datetime.timedelta`` → ``std::chrono::duration`` 68 Time delta are converted into durations with microsecond precision. 69 70- ``datetime.timedelta`` → ``std::chrono::[other_clocks]::time_point`` 71 Time deltas that are converted into clock timepoints are treated as 72 the amount of time from the start of the clocks epoch. 73 74- ``float`` → ``std::chrono::duration`` 75 Floats that are passed to C++ as durations be interpreted as a number of 76 seconds. These will be converted to the duration using ``duration_cast`` 77 from the float. 78 79- ``float`` → ``std::chrono::[other_clocks]::time_point`` 80 Floats that are passed to C++ as time points will be interpreted as the 81 number of seconds from the start of the clocks epoch. | 63 Date/time objects are converted into system clock timepoints. Any 64 timezone information is ignored and the type is treated as a naive 65 object. 66 67- ``datetime.timedelta`` → ``std::chrono::duration`` 68 Time delta are converted into durations with microsecond precision. 69 70- ``datetime.timedelta`` → ``std::chrono::[other_clocks]::time_point`` 71 Time deltas that are converted into clock timepoints are treated as 72 the amount of time from the start of the clocks epoch. 73 74- ``float`` → ``std::chrono::duration`` 75 Floats that are passed to C++ as durations be interpreted as a number of 76 seconds. These will be converted to the duration using ``duration_cast`` 77 from the float. 78 79- ``float`` → ``std::chrono::[other_clocks]::time_point`` 80 Floats that are passed to C++ as time points will be interpreted as the 81 number of seconds from the start of the clocks epoch. |