From: demoness AT erols DOT com (Dominia) Subject: Problem with Grabbing System Time 20 Dec 1998 11:21:10 -0800 Message-ID: <367D2692.2374B022.cygnus.gnu-win32@erols.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------99560D1595056CACD8722CCF" To: gnu-win32 AT cygnus DOT com --------------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 #include 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 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-- - 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".