This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

localtime compatibility



I apologize in advance if this is a FAQ, but I've been having some
compatibility problems with static executables and the localtime call.
Here is a dumby program:



#include <stdio.h>
#include <time.h>

int main()
{
  time_t now = time (NULL);
  struct tm *now_tm = localtime (&now);

  system ("date");
  
  printf ("year:   %d\n", now_tm->tm_year);
  printf ("month:  %d\n", now_tm->tm_mon + 1); /* [0-11] -> [1-12] */
  printf ("day:    %d\n", now_tm->tm_mday);
  printf ("hour:   %d\n", now_tm->tm_hour);
  printf ("minute: %d\n", now_tm->tm_min);
  printf ("second: %d\n", now_tm->tm_sec);
}



Now, if I build this statically on a machine with glibc-2.1.x (or
glibc-2.0.x, for that matter):

gcc test.c -o test -static

it will obviously run fine on any machine with glibc-2.x, and even a test
machine with libc-5.3.12-17.  However, if I build the program statically 
on the libc box, it runs fine on the glibc-2.0.x system, but under
glibx-2.1.x, the results don't seem to take into account timezone:

	Tue Nov  2 12:04:17 CST 1999
	year:   99
	month:  11
	day:    2
	hour:   18
	minute: 4
	second: 17

(the hour is off by the timezone offset)

How did time zone handling change over the course of libc - glibc
evolution?  Any enlightenment would be greatly appreciated.

Thanks

- Andy Ritger




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]