[flang-commits] [flang] [llvm] [flang-rt] Add implementation for date_and_time on Windows (PR #190174)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Thu Apr 2 07:35:08 PDT 2026


================
@@ -399,6 +410,41 @@ template <typename TM = struct tm> struct GmtOffsetHelper {
   };
 };
 
+#ifdef _WIN32
+struct timeval {
+  std::int64_t tv_sec;
+  std::int64_t tv_usec;
+};
+
+// gettimeofday half-implementation for win32; ignore the timezone as we don't
+// use it anyway
+int gettimeofday(timeval *tv, void *) {
+  constexpr std::uint64_t epoch_offset{116444736000000000ull};
+
+  FILETIME ftime;
+  GetSystemTimePreciseAsFileTime(&ftime);
+
+  // Convert ftime to a real 64-bit integer
+  std::uint64_t time{
+      ULARGE_INTEGER{{ftime.dwHighDateTime, ftime.dwHighDateTime}}.QuadPart};
----------------
tblah wrote:

```suggestion
      ULARGE_INTEGER{{ftime.dwLowDateTime, ftime.dwHighDateTime}}.QuadPart};
```

Or did I miss something here?

https://github.com/llvm/llvm-project/pull/190174


More information about the flang-commits mailing list