Subject: Problem with Grabbing System Time
From: [email-masked] (Dominia)

20 Dec 1998 11:21:10 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------99560D1595056CACD8722CCF"
To: [email-masked]

--------------99560D1595056CACD8722CCF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Greetings,

I was having some trouble with porting a Unix application to Windows in
that the gettimeofday doesn't seem to be working correctly. The larger
program I am working with is returning:

Wed Feb 11 21:21:36 1970

as the current system time, but my system clock was set to:

Sun Dec 20 11:13:23 1998

when the "time" command was run.

I tried running the following snippet to check what actual time my
system was returning. It consistently returns dates from February of
1970.

3 1 11 21:33:39 70 ( this is equivalent to Wed Feb 11 21:33:39 1970 )

At least it's incrementing the clock, but I can't figure out why it's
not current. Is there something I am missing? Whatever it is, I am just
not seeing it. Is it my system? Is it me? What?? Any help would be
appreciated.

Thanks,

Paula

(The following was compiled via gcc on the command line with just "gcc
test.c" and then I ran ./a.out and got the results I reported above.)

     #include <sys/types.h>
     #include <sys/time.h>
     main() {
         struct timeval tp; struct timezone tzp;
         struct tm *lt;
         long secs1970;

         gettimeofday(&tp, &tzp);
         secs1970= tp.tv_sec;
         lt = localtime(&secs1970);
         printf("%d %d %d %d:%d:%d %d\n",
         lt->tm_wday, lt->tm_mon,  lt->tm_mday,
         lt->tm_hour, lt->tm_min,  lt->tm_sec, lt->tm_year
         );
     }

--------------99560D1595056CACD8722CCF
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<b><tt>Greetings,</tt></b>
<p><b><tt>I was having some trouble with porting a Unix application to
Windows in that the gettimeofday doesn't seem to be working correctly.
The larger program I am working with is returning:</tt></b>
<p><b><tt>Wed Feb 11 21:21:36 1970</tt></b>
<p><b><tt>as the current system time, but my system clock was set to:</tt></b>
<p><b><tt>Sun Dec 20 11:13:23 1998</tt></b>
<p><b><tt>when the "time" command was run.</tt></b>
<p><b><tt>I tried running the following snippet to check what actual time
my system was returning. It consistently returns dates from February of
1970.</tt></b>
<p><b><tt>3 1 11 21:33:39 70 ( this is equivalent to Wed Feb 11 21:33:39
1970 )</tt></b>
<p><b><tt>At least it's incrementing the clock, but I can't figure out
why it's not current. Is there something I am missing? Whatever it is,
I am just not seeing it. Is it my system? Is it me? What?? Any help would
be appreciated.</tt></b>
<br><b><tt></tt></b>&nbsp;<b><tt></tt></b>
<p><b><tt>Thanks,</tt></b><b><tt></tt></b>
<p><b><tt>Paula</tt></b><b><tt></tt></b>
<p><b><tt>(The following was compiled via gcc on the command line with
just "gcc test.c" and then I ran ./a.out and got the results I reported
above.)</tt></b>
<br>&nbsp;
<p><b><tt>&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;sys/types.h></tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp; #include &lt;sys/time.h></tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp; main() {</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct timeval
tp; struct timezone tzp;</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct tm *lt;</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long secs1970;</tt></b>
<p><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gettimeofday(&amp;tp,
&amp;tzp);</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; secs1970= tp.tv_sec;</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lt = localtime(&amp;secs1970);</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%d
%d %d %d:%d:%d %d\n",</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lt->tm_wday,
lt->tm_mon,&nbsp; lt->tm_mday,</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lt->tm_hour,
lt->tm_min,&nbsp; lt->tm_sec, lt->tm_year</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );</tt></b>
<br><b><tt>&nbsp;&nbsp;&nbsp;&nbsp; }</tt></b></html>

--------------99560D1595056CACD8722CCF--

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".