localtime(3) function output not Y2K?

From: Salvador Ramirez <sram_at_profc.udec.CL>
Date: Fri, 12 Mar 1999 22:04:36 -0300 (CDT)

I have done a little C program to get the local time and I used
localtime(3) to do that but I get a not expected output. In
/usr/include/time.h is defined the struct "tm" which one of its
fields is an integer called tm_year for storing the year but
this field show only (at this time) 99!.
Another question is if you have man page for the "time" C function?
on my system I only get the man pages for time(1) command.
My program looks like the following:

...
struct tm *test;
time_t tim;

 tim = time(0);
 test = (struct tm *)localtime( &tim );
 
printf("%d\n", test->tm_year);
...

I know that asctime(3) return a string that have the complete
specification of the year (1999) but I would like to use localtime
because it return the day, hour, ..., year in different fields that
you can manipulate. Is this a localtime bug or now there is a
function that get the current century?.. I don't think so but it
maybe would be useful

Thank you in advance!

---sram
               If God does not exist, it would be necessary
                         to invent him --Voltaire
Salvador Ramirez Flandes PROFC, Universidad de Concepcion, CHILE
http://www.profc.udec.cl/~sram mailto:sram_at_profc.udec.cl
Received on Sat Mar 13 1999 - 01:08:55 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:39 NZDT