Technical article 109280

SCO OpenServer 5 mktime(S) doesn't correctly handle the leap year in year 2000.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5

Written · Last revised

Problem

The SCO OpenServer Release 5 mktime(S) function does not correctly calculate the leap year that occurs in the year 2000.

This can be shown using the code fragment detailed below. If executed on SCO OpenServer 5.0.4, it produces:

Start time "29-02-2000 23:23:00" Add one hour, expect "01-03-2000 00:23:00" Got "02-03-2000 00:23:00" Expected difference 3600 sec, Got 90000 sec

On UnixWare 7, mktime(3C) reports correctly:

Start time "29-02-2000 23:23:00" Add one hour, expect "01-03-2000 00:23:00" Got "01-03-2000 00:23:00" Expected difference 3600 sec, Got 3600 sec

Note: The date format used is DD-MM-YYYY.

Note: Using cc without any options will produce a static binary.
It would therefore be necessary to have the SCO OpenServer
Development System installed prior to applying any of the Year
2000 supplements.  In order to get a dynamically linked binary
that you could test any system with, you would need to compile
an ELF binary using: cc -b elf <file name>.  See the NOTE following
the SOLUTION below for more information.
# cc <file name>
/* for a COFF binary, can be used to tested systems with the Development System
installed prior to the installation of any year 2000 supplement */
# cc -b elf <file name>
/* for an ELF binary, can be used to test any system with year 2000 supplement
installed */
**************cut here*****************
#include <time.h>
static  struct tm curr_time;
main() {
time_t       t1, t2;
char         tim[100];

curr_time.tm_min = 23; curr_time.tm_hour = 23; curr_time.tm_mday = 29; curr_time.tm_mon = 1; /* Feb */ curr_time.tm_year = 100; /* 2000 */

                   /* Build the time 29-2-2000 23:23:00 */
                   t1 = mktime(&curr_time);
                   strftime(tim, sizeof(tim), "%d-%m-%Y %H:%M:%S",
&curr_time);
                   printf("Start time \"%s\"\n", tim);
                   /* Add one hour and normalize */
                   curr_time.tm_hour++;
                   t2 = mktime(&curr_time);
                   strftime(tim, sizeof(tim), "%d-%m-%Y %H:%M:%S",
&curr_time);
   printf("Add one hour, expect \"01-03-2000 00:23:00\"
   Got \"%s\"\n", tim);
   printf("Expected difference 3600 sec,
   Got %d sec\n", (int)difftime(t2, t1));
}
****************cut here*******************

Solution

This problem has been addressed with the following supplements:

SLS OSS603A for OpenServer 5.0.0, SDK or UDK installed before OSS603A

SLS OSS601A for OpenServer 5.0.2 and 5.0.4, SDK or UDK installed before OSS601A

Release Supplement 505A (rs505a) for OpenServer 5.0.5, SDK or UDK installed before rs505a

NOTE:     The above supplements contain fixes to both the dynamic shared and
          static C libraries.  Since the dynamic shared C library is part
          of the base operating system, while the static C library is part of
          the OpenServer Development System, you must install the OpenServer
          Development system prior to installing the relevant supplement in
          order to obtain the fixed static C library.

Thus, if your applications contain statically linked binaries, the mktime(S) issue above will only be resolved if you 1) install the relevant supplement _after_ installing the Development System, 2) recompile/relink your application binaries after installation of the supplement.

In contrast, if you have dynamically linked binaries, the mktime(S) issue will be resolved following a reboot of the system, after installing the relevant supplement.

See also

ta110166, "What is addressed by SLS OSS603A, the Year 2000 Supplement for SCO OpenServer 5.0.0 with rs500d and net100?"

ta110077, "What is addressed by SLS OSS601A, the Year 2000 Supplement for SCO OpenServer 5.0.2 and 5.0.4?".

ta109909, "What is Release Supplement 505A for SCO OpenServer Release 5.0.5?".

manual page: mktime(S)

From the Xinuos technical article database, record 109280. Reproduced with permission. The original is at www.sco.com/ta/109280, which is reachable but blocked from search engines.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.