AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  Calling mktime on AIX 6.1

    Posted 06/07/13 11:19 AM

    Originally posted by: DavidTopham


    I have an issue with our software on an AIX 6.1. 

    Our software uses the mktime() call. We are seeing different behaviurs on two different AIX 6.1 installations, which are at different technology levels. Here is a code snippet that demonstrates the behaviour we are seeing:

        struct tm tmTime;
        time_t ttTime;
        memset(&tmTime, 0, sizeof(tmTime));
    
        // Set time to 1 Oct 2006
        tmTime.tm_year = 106;
        tmTime.tm_mon = 9;
        tmTime.tm_mday = 1;
    
        ttTime = mktime(&tmTime);
        printf("TM1: %d %d %d %d %d %d %d %d %d\n", tmTime.tm_sec, tmTime.tm_min, tmTime.tm_hour, 
                                                  tmTime.tm_mday, tmTime.tm_mon, tmTime.tm_year, 
                                                  tmTime.tm_wday, tmTime.tm_yday, tmTime.tm_isdst);
        printf("TT1: %d\n", ttTime);
        printf("AT1: %s\n", asctime(&tmTime));
    
    
        /* Add 2792 days*/
        tmTime.tm_mday += 2792;
    
        /* Call mktime again to normalise */
        ttTime = mktime(&tmTime);
        printf("TM2: %d %d %d %d %d %d %d %d %d\n", tmTime.tm_sec, tmTime.tm_min, tmTime.tm_hour, 
                                                  tmTime.tm_mday, tmTime.tm_mon, tmTime.tm_year, 
                                                  tmTime.tm_wday, tmTime.tm_yday, tmTime.tm_isdst);
    
        printf("TT2: %d\n", ttTime);
        printf("AT2: %s\n", asctime(&tmTime));
    

     

    On AIX 6.1 TL1 (6100-01-01-0823), I get this output, which is what I expect to see:

    TM1: 0 0 1 1 9 106 0 273 1
    TT1: 1159682400
    AT1: Sun Oct  1 01:00:00 2006
     
    TM2: 0 0 1 24 4 114 6 143 1
    TT2: 1400911200
    AT2: Sat May 24 01:00:00 2014

    In other words, adding 2792 days to the date, then calling mktime again to normalise it, has moved the time to 24 May 2014. (Note: whilst not everyone is familiar with it, the ability to add days (or whatever) to a tm structure then renormalise it with a call to mktime is expected and correct behaviour for the mktime function). 

    On AIX6.1 TL0 (6100-00-03-0808), however, I get this output:

    TM1: 0 0 0 1 9 106 0 0 0
    TT1: 1159678800
    AT1: Sun Oct  1 00:00:00 2006
     
    TM2: 0 0 0 2793 9 106 0 0 0
    TT2: 1400907600
    AT2: Sun Oct 93 00:00:00 2006
     
    In other words, the second call to mktime has not normalised the tm structure as expected. 

    So it appears that there may have been an issue in TL 0 that was resolved in TL 1. However, I am struggling to confirm this, as I only have one box for each and cannot discount that something else could be the cause.

    Did changes occur in AIX 6.1 between TL 0 and TL 1 that could account for this change in behaviour? Looking at the TL1 release notes on Fix Central, there are some fixes for mktime mentioned, but nothing exactly like this. If it was an issue in TL0 and it was fixed in TL1, that's fine, I can stipulate TL 1 as a minimum (yes, I realise TL0 and TL1 are both old and out of service now). 

    Thanks.


    #AIX-Forum


  • 2.  Re: Calling mktime on AIX 6.1

    Posted 06/10/13 10:04 AM

    Originally posted by: flodstrom


    If I recall there were indeed some obscure time related issues (like tzset() and mktime() ) in vanilla AIX 6.1. It may be difficult to find what fixed the issues or the time when it was fixed. I think the root cause was in libc itself and that fix solved a lot of other reported problems so the fix may have been labelled as something else?

    You should probably contact IBM if you need to have a proper answer, but since TL0 and TL1 is really old they may just tell you to update.

    Anyway I can confirm that it works properly in AIX 6.1 TL7 so it may be safe to say that anything newer than TL1 should be okay? However I don't have anything older than AIX 6.1 TL7 to test the code on.

     


    #AIX-Forum


  • 3.  Re: Calling mktime on AIX 6.1

    Posted 06/11/13 10:41 AM

    Originally posted by: DavidTopham


    Thanks for the response, and for testing the code on TL7.

    Yes, I did see some issues related to mktime in the release notes, but more related to timezones than what I'm seeing here. However, I'm prepared to believe that it could have been included under a general fix - there appears to have been a LOT of stuff in TL1. 

    And you're right, there both TL0 and TL1 are old. It's reasonable to ask people to upgrade in this situation. 

    Thanks again for the response. 


    #AIX-Forum