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]

Re: Y2K question


On Wed, Feb 02, Wolfgang Sourdeau wrote:

> Hi,
> 
> I was wondering why the next code returned 100 as year when current date
> is past y2k. 
> 
> #include <stdio.h>
> #include <time.h>
> 
> int main()
> {
>         time_t seconds70;
>         struct tm *timeinfo;
> 
>         seconds70 = time(&seconds70);
>         timeinfo = gmtime(&seconds70);
>         printf( "%.2d/%.2d/%.2d\n",
>                         timeinfo->tm_mday,
>                         (timeinfo->tm_mon + 1),
>                         timeinfo->tm_year);
> 
>         return 0;
> }
> 
> Is it to make the difference between 1900 and 2000 ?
> 
> In any way, in my sense, it's more of a bug than a feature because
> obviously timeinfo->tm_year is mean to be a 2-digits value. Has anyone
> any explaination on this ?
> 

Where stands that timeinfo->tm_year mean to be a 2-digit value ?
tm_year is defined as Year - 1900, so everything is correct.

  Thorsten

-- 
Thorsten Kukuk       http://www.suse.de/~kukuk/       kukuk@suse.de
SuSE GmbH            Schanzaeckerstr. 10            90443 Nuernberg
Linux is like a Vorlon.  It is incredibly powerful, gives terse,
cryptic answers and has a lot of things going on in the background.

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