Mail Archives: cygwin/1998/12/20/11:21:10
--------------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> <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>
<p><b><tt> #include <sys/types.h></tt></b>
<br><b><tt> #include <sys/time.h></tt></b>
<br><b><tt> main() {</tt></b>
<br><b><tt> struct timeval
tp; struct timezone tzp;</tt></b>
<br><b><tt> struct tm *lt;</tt></b>
<br><b><tt> long secs1970;</tt></b>
<p><b><tt> gettimeofday(&tp,
&tzp);</tt></b>
<br><b><tt> secs1970= tp.tv_sec;</tt></b>
<br><b><tt> lt = localtime(&secs1970);</tt></b>
<br><b><tt> printf("%d
%d %d %d:%d:%d %d\n",</tt></b>
<br><b><tt> lt->tm_wday,
lt->tm_mon, lt->tm_mday,</tt></b>
<br><b><tt> lt->tm_hour,
lt->tm_min, lt->tm_sec, lt->tm_year</tt></b>
<br><b><tt> );</tt></b>
<br><b><tt> }</tt></b></html>
--------------99560D1595056CACD8722CCF--
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".
- Raw text -