Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8250636

iso8601_time returns incorrect offset part on MacOS

    Details

    • Subcomponent:
    • Resolved In Build:
      b11

      Backports

        Description

        The problem is in the get_timezone function.

        src/hotspot/share/runtime/os.cpp

        static time_t get_timezone(const struct tm* time_struct) {
        #if defined(_ALLBSD_SOURCE)
          return time_struct->tm_gmtoff;
        #elif defined(_WINDOWS)
          long zone;
          _get_timezone(&zone);
          return static_cast<time_t>(zone);
        #else
          return timezone;
        #endif
        }

        The call to get_timezone works fine on Mac but it returns undeclared "timezone" on Linux.

        According to the doc for the tm_gmtoff member:
        “The tm_gmtoff field is derived from BSD and is a GNU library extension; it is not visible in a strict ISO C environment.”

        It might make sense to return time_struct->tm_gmtof if _GNU_SOURCE is defined. Attached a candidate patch.

          Attachments

          1. get_timezone_v2.patch
            0.4 kB
          2. get_timezone_v2.patch
            2 kB
          3. get_timezone_v3.patch
            2 kB
          4. get_timezone.patch
            0.4 kB

            Issue Links

              Activity

                People

                • Assignee:
                  dcherepanov Dmitry Cherepanov
                  Reporter:
                  dcherepanov Dmitry Cherepanov
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  8 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: