Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-50559

The mktime() output is different since RHEL9 if tm.tm_isdst is set to 1.

    • No
    • Important
    • ee768a30fe9099972dad04c49972c2508a208b9b
    • 3
    • sst_pt_libraries
    • ssg_platform_tools
    • 1
    • False
    • Hide

      None

      Show
      None
    • None
    • Red Hat Enterprise Linux
    • SST PT Libraries Sprint 8, SST PT Libraries Sprint 9, SST PT Libraries Sprint 10
    • None
    • None
    • x86_64
    • None

      What were you trying to do that didn't work?

      We observe the tm_isdst of mktime() has changed since RHEL9.2.

      Please provide the package NVR for which bug is seen:

      How reproducible:

      Steps to reproduce

      1. Using the c program to run on the RHEL9.2 above.
      #include <stdio.h>
      #include <time.h>
      
      int main()
      {
      time_t daylight, standard;
      struct tm timestr;
      double diff;
      
      timestr.tm_year = 2012 - 1900;
      timestr.tm_mon = 11 - 1;
      timestr.tm_mday = 4;
      timestr.tm_hour = 1;
      timestr.tm_min = 30;
      timestr.tm_sec = 0;
      
      /* first with standard time */
      timestr.tm_isdst = 0;
      standard = mktime(&timestr);
      
      /* now with daylight time */
      timestr.tm_isdst = 1;
      daylight = mktime(&timestr);
      
      diff = difftime(standard, daylight);
      
      printf("Difference is %f hour(s)", diff/60.0/60.0);
      
      return 0;
      }
      
      1.  gcc test.c -o test&&chmod +x test
      2.  ./test
      3.  we can see whether the system timezone is DST, it is always 1-hour offset.
      [root@node-0 timedst_test]# cat /etc/redhat-release
      Red Hat Enterprise Linux release 9.4 (Plow)
      [root@node-0 timedst_test]# timedatectl set-timezone Europe/London
      [root@node-0 timedst_test]# ./test
      Difference is 1.000000 hour(s)
      [root@node-0 timedst_test]# timedatectl set-timezone Asia/Hong_Kong
      [root@node-0 timedst_test]# ./test
      Difference is 1.000000 hour(s)
      

      Expected results

      It should be no time offset like RHEL8:

      [root@node-0 timedst_test]# timedatectl set-timezone Asia/Hong_Kong
      [root@node-0 timedst_test]# cat /etc/redhat-release
      Red Hat Enterprise Linux release 8.5 (Ootpa)
      [root@node-0 timedst_test]# ./test
      Difference is 0.000000 hour(s)
      

      Actual results

      It is always 1-hour offset since RHEL9.2.

            rhn-engineering-dj DJ Delorie
            rhn-support-yalu Yanquan Lu
            Florian Weimer
            DJ Delorie DJ Delorie
            qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com
            Votes:
            1 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: