MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / convertFiletime

Function convertFiletime

test/host/wasi/wasi.cpp:220–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218#else
219
220__wasi_timestamp_t
221convertFiletime(WasmEdge::winapi::FILETIME_ FileTime) noexcept {
222 using std::chrono::duration_cast;
223 using std::chrono::nanoseconds;
224 using FiletimeDuration = std::chrono::duration<
225 uint64_t, std::ratio_multiply<std::ratio<100, 1>,
226 std::chrono::nanoseconds::period>>;
227 /// from 1601-01-01 to 1970-01-01, 134774 days
228 constexpr const FiletimeDuration NTToUnixEpoch =
229 std::chrono::seconds{134774LL * 86400LL};
230 WasmEdge::winapi::ULARGE_INTEGER_ Temp = {
231 /* LowPart */ FileTime.dwLowDateTime,
232 /* HighPart */ FileTime.dwHighDateTime};
233 auto Duration = duration_cast<nanoseconds>(FiletimeDuration{Temp.QuadPart} -
234 NTToUnixEpoch);
235 return static_cast<__wasi_timestamp_t>(Duration.count());
236}
237#endif
238
239// The following code includes a sleep to prevent a possible delay when sending

Callers 1

TESTFunction · 0.85

Calls 1

countMethod · 0.80

Tested by

no test coverage detected