MCPcopy Create free account
hub / github.com/pybind/pybind11 / localtime_thread_safe

Function localtime_thread_safe

include/pybind11/chrono.h:104–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102};
103
104inline std::tm *localtime_thread_safe(const std::time_t *time, std::tm *buf) {
105#if (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__)) || defined(_MSC_VER)
106 if (localtime_s(buf, time))
107 return nullptr;
108 return buf;
109#else
110 static std::mutex mtx;
111 std::lock_guard<std::mutex> lock(mtx);
112 std::tm *tm_ptr = std::localtime(time);
113 if (tm_ptr != nullptr) {
114 *buf = *tm_ptr;
115 }
116 return tm_ptr;
117#endif
118}
119
120// This is for casting times on the system clock into datetime.datetime instances
121template <typename Duration>

Callers 1

castMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected