[flang-commits] [flang] [flang] Update the date_and_time intrinsic for AIX (PR #104849)
via flang-commits
flang-commits at lists.llvm.org
Mon Aug 26 09:45:17 PDT 2024
================
@@ -247,6 +247,59 @@ static void DateAndTimeUnavailable(Fortran::runtime::Terminator &terminator,
}
#ifndef _WIN32
+#ifdef _AIX
+// Compute the time difference from GMT/UTC to get around the behavior of
+// strfname on AIX that requires setting an environment variable for numeric
+// value for ZONE.
+// The ZONE and the VALUES(4) arguments of the DATE_AND_TIME intrinsic has
+// the resolution to the minute.
+static int computeUTCDiff(const tm &localTime, bool *err) {
+ tm utcTime;
+ const time_t timer{mktime(const_cast<tm *>(&localTime))};
+ if (timer < 0) {
+ *err = true;
+ return 0;
+ }
+
+ // Get the GMT/UTC time
+ if (gmtime_r(&timer, &utcTime) == nullptr) {
+ *err = true;
+ return 0;
+ }
+
+ // Adjust for day difference
+ auto dayDiff{localTime.tm_mday - utcTime.tm_mday};
+ auto localHr{localTime.tm_hour};
+ if (dayDiff > 0) {
+ if (dayDiff == 1)
----------------
jeanPerier wrote:
nit: if/then/else are always braced inside runtime code.
https://github.com/llvm/llvm-project/pull/104849
More information about the flang-commits
mailing list