Problem with Grabbing System Time

Brian Smith Brian.Smith@PicoDyne.com
Sun Dec 20 20:22:00 GMT 1998


Not 
sure I can tell you anything specific, but that date seems awfully close to the 
UNIX epoch, or time zero.  Perhaps you aren't adding an offset to get 
todays date.
 
Brian
 

-        Brian S. 
Smith -     PicoDyne Corporation -  Annapolis 
Engineering Office -(v)410-266-8828 (fax)410-266-8872 

    -----Original Message----- From: owner-gnu-win32@cygnus.com 
    [mailto:owner-gnu-win32@cygnus.com] On Behalf Of 
    Dominia Sent: Sunday, December 20, 1998 11:32 AM To: gnu-win32@cygnus.com Subject: 
    Problem with Grabbing System 
    Time 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 
             ); 
         } 



More information about the Cygwin mailing list