Your code is completely wrong.

> Not sure if my code is wrong, or if sparc64 has a bug?
> 
> The following code produces different results on sparc64 vs i386.
> 
> i386 results:
> $ ./code
> seconds: 1357170317
> year: 2013
> 
> sparc64 results:
> $ ./code
> seconds: 1357170432
> year: 1969
> 
> 
> /*
>  * code
>  */
> #include <sys/types.h>
> #include <sys/time.h>
> #include <time.h>
> #include <stdio.h>
> 
> int
> main(void)
> {
>         struct timeval tp;
>         struct tm *tm, tmBuf;
> 
>         if (gettimeofday(&tp, NULL) == -1)
>                 perror("gettimeofday");
> 
>         printf("seconds: %ld\n", tp.tv_sec);
> 
>         tm = localtime_r((time_t *)&(tp.tv_sec), &tmBuf);
> 
>         printf("year: %d\n", tm->tm_year + 1900);
>         return (0);
> }

Reply via email to