19 {
20 nb::module_ m_clock_ns = m.def_submodule("clock_ns", "Clock utilities with nanosecond precision");
21
22 nb::class_<PClockNs>(m_clock_ns, "PClockNs")
23
24 .def(nb::init<>())
25
26
27 .def_prop_rw("offsetTimeNs",
28 [](PClockNs &c) { return c.getOffsetTimeNs(); },
29 [](PClockNs &c, time_t value) { c.setOffsetTimeNs(value); })
30
31
32 .def("getFullTimeNs", &PClockNs::getFullTimeNs,
33 "Get the full time in nanoseconds")
34
35 .def("getDateNs", &PClockNs::getDateNs,
36 "Get the date at nanosecond precision")
37
38 .def("getDateCompactNs", &PClockNs::getDateCompactNs,
39 "Get the date at nanosecond precision in compact format")
40
41 .def("now", &PClockNs::now,
42 "Get the full time in nanoseconds (alias for getFullTimeNs)")
43
44 .def("sleep", [](const PClockNs &c, time_t ellapsedTime) {
45 c.sleep(ellapsedTime);
46 },
47 "Sleep for the given elapsed time in nanoseconds"
48 );
49}