[flang-commits] [lldb] [libcxx] [clang] [clang-tools-extra] [flang] [compiler-rt] [libc] [llvm] [flang] FDATE extension implementation: get date and time in ctime format (PR #71222)

via flang-commits flang-commits at lists.llvm.org
Tue Nov 21 05:32:11 PST 2023


================
@@ -10,9 +10,26 @@
 // extensions that will eventually be implemented in Fortran.
 
 #include "flang/Runtime/extensions.h"
+#include "terminator.h"
 #include "flang/Runtime/command.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
+#include "flang/Runtime/time-intrinsic.h" // copyBufferAndPad
+#include <ctime>
+
+#ifdef _WIN32
+inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time,
+    Fortran::runtime::Terminator terminator) {
+  int error = ctime_s(buffer, bufsize, &cur_time);
+  RUNTIME_CHECK(terminator, error == 0);
+}
+#else
+inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time,
+    Fortran::runtime::Terminator terminator) {
+  const char *res = ctime_r(&cur_time, buffer);
----------------
jeanPerier wrote:

LGTM, thanks

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


More information about the flang-commits mailing list