[LCP]time 1e9

Steve Fraser sfraser at sierra.apana.org.au
Fri Aug 24 22:56:04 UTC 2001


Hi Joachim,

Try setting the variable "now" to 2147483647.

This is about one fifth of your value (which had ten zeros!), and is also
the value defined for MAXLONG in values.h.

(time_t is a long)

Looks like Tue Jan 19 13:44:07 2038 will be a fun time in the Unix world!

cheers

Steve

PS with nine zeros (which is what I think you intended) your program gives
Sun Sep  9 11:16:40 2001.

PPS I always use -Wall on my compiles - it helps a lot :-)

----- Original Message -----
From: "Joachim Bauernberger" <bj at gmx.net>
To: <linuxCprogramming at lists.linux.org.au>
Sent: Friday, August 24, 2001 9:34 PM
Subject: [LCP]time 1e9


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
> I was wondering how i get the calendertime from the seconds as in:
>
> #include <time.h>
> #include <stdio.h>
>
> int main( int argc, char **argv) {
>
> /* soemwhen on the 9th of sept. 2001 unixtime will reach 1e9 */
>         time_t          now = 10000000000;
>
>         struct tm       *tt;
>         char *c;
>
>         tt = localtime(&now);
>         c = ctime(&now);
>
>         fprintf(stdout,"%d %d %d %d %d %d %d",tt->tm_sec, tt->tm_min,
> tt->tm_hour, tt->tm_mday, tt->tm_mon, tt->tm_year, tt->tm_wday);
>         fprintf(stdout,"\n%s\n",c);
>
> return 0;
> }
>
> This yields a date somewhen in 2014 Which isn't correct. Can somebody
please
> point out to me what I am missing.
>
> Thank's
> Joachim
>
> - --
> Warning: Your HTML-mail goes straight to my trash!
> You can get my public pgp key here:
> http://foobar.gmxhome.de/joachim.txt
> PGP fingerprint:
> 25 96 E0 25 48 D9 8E 10  3C C0 48 E7 AF 5A E2 C6  A3 15 05 E6
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 6.5.8
>
> iQA/AwUBO4ZC5a9a4sajFQXmEQKTKgCgpkVa4WMqrm/zPRDxJQSHHsp9/usAoJBQ
> 2G/zoTHMTmFZkYRj8BImEHNU
> =uBfJ
> -----END PGP SIGNATURE-----
> _______________________________________________
> This is the Linux C Programming List
> :  http://lists.linux.org.au/listinfo/linuxcprogramming List
>




More information about the linuxCprogramming mailing list