Problem
I have compiled the following sample code using the command:
cc -o foo foo.c -Xm -a ods30 -b coffIf I run the resulting binary on SCO UNIX System V/386 Release 3.2 Operating System Version 4.2 or SCO Open Server Release 3.0, the time displayed is incorrect, if Daylight Savings time is active on the system.
For example, the date(C) command on SCO UNIX Operating System Version 4.2 returns:
04:01:24 PM Tue 15 Oct 1996 BSTbut the following code returns:Local time is [Tue Oct 15 15:01:24 1996]It does not take into account the time zone environment variable
tz(M).#include <stdio.h>
#include <time.h>void main()
{
char datetime[25];
long clock;time(&clock);
strncpy(datetime,ctime(&clock),24);
datetime[24] = 0; printf("Local time is [%s]\n",datetime);
} Cause
There is a problem with the ctime(S) and localtime(S) library functions that causes them to fail when run on SCO UNIX Version 4.2 and SCO Open Server Release 3.0 based systems.
Solution
This problem has been reported to SCO Engineering.