Subject: RE: Problem with Grabbing System Time
From: [email-masked] (Brian Smith)

20 Dec 1998 20:53:27 -0800
Message-ID: <002e01be2c86$8feff4a0$44032599.cygnus.gnu-win32@fred>
References: <[email-masked]>
Reply-To: <[email-masked]>
Mime-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_000_002F_01BE2C5C.A71B7340"
To: "Gnu-Win32@Cygnus. Com" <[email-masked]>

This is a multi-part message in MIME format.

------=_NextPart_000_002F_01BE2C5C.A71B7340
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

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: [email-masked] [mailto:[email-masked]]On
Behalf Of Dominia
    Sent: Sunday, December 20, 1998 11:32 AM
    To: [email-masked]
    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
             );
         }

------=_NextPart_000_002F_01BE2C5C.A71B7340
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3110.7"' name=3DGENERATOR>
</HEAD>
<BODY>
<DIV><SPAN class=3D240055701-21121998><FONT color=3D#0000ff face=3DArial =
size=3D2>Not=20
sure I can tell you anything specific, but that date seems awfully close =
to the=20
UNIX epoch, or time zero.&nbsp; Perhaps you aren't adding an offset to =
get=20
todays date.</FONT></SPAN></DIV>
<DIV><SPAN class=3D240055701-21121998><FONT color=3D#0000ff face=3DArial =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D240055701-21121998><FONT color=3D#0000ff face=3DArial =

size=3D2>Brian</FONT></SPAN></DIV>
<DIV><SPAN class=3D240055701-21121998><FONT color=3D#0000ff face=3DArial =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV>
<P><FONT size=3D2>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Brian S.=20
Smith<BR>-&nbsp;&nbsp;&nbsp;&nbsp; PicoDyne Corporation<BR>-&nbsp; =
Annapolis=20
Engineering Office<BR>-(v)410-266-8828 (fax)410-266-8872 =
</FONT></P></DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #0000ff solid 2px; MARGIN-LEFT: 5px; PADDING-LEFT: =
5px">
    <DIV class=3DOutlookMessageHeader><FONT face=3D"Times New Roman"=20
    size=3D2>-----Original Message-----<BR><B>From:</B> =
[email-masked]=20
    [mailto:[email-masked]]<B>On Behalf Of</B>=20
    Dominia<BR><B>Sent:</B> Sunday, December 20, 1998 11:32 =
AM<BR><B>To:</B> <A=20
    =
href=3D"mailto:[email-masked]">[email-masked]</A><BR><B>Subje=
ct:</B>=20
    Problem with Grabbing System=20
    Time<BR><BR></FONT></DIV><B><TT>Greetings,</TT></B>=20
    <P><B><TT>I was having some trouble with porting a Unix application =
to=20
    Windows in that the gettimeofday doesn't seem to be working =
correctly. The=20
    larger program I am working with is returning:</TT></B>=20
    <P><B><TT>Wed Feb 11 21:21:36 1970</TT></B>=20
    <P><B><TT>as the current system time, but my system clock was set=20
    to:</TT></B>=20
    <P><B><TT>Sun Dec 20 11:13:23 1998</TT></B>=20
    <P><B><TT>when the &quot;time&quot; command was run.</TT></B>=20
    <P><B><TT>I tried running the following snippet to check what actual =
time my=20
    system was returning. It consistently returns dates from February of =

    1970.</TT></B>=20
    <P><B><TT>3 1 11 21:33:39 70 ( this is equivalent to Wed Feb 11 =
21:33:39=20
    1970 )</TT></B>=20
    <P><B><TT>At least it's incrementing the clock, but I can't figure =
out why=20
    it's not current. Is there something I am missing? Whatever it is, I =
am just=20
    not seeing it. Is it my system? Is it me? What?? Any help would be=20
    appreciated.</TT></B> <BR><B><TT></TT></B>&nbsp;<B><TT></TT></B>=20
    <P><B><TT>Thanks,</TT></B><B><TT></TT></B>=20
    <P><B><TT>Paula</TT></B><B><TT></TT></B>=20
    <P><B><TT>(The following was compiled via gcc on the command line =
with just=20
    &quot;gcc test.c&quot; and then I ran ./a.out and got the results I =
reported=20
    above.)</TT></B> <BR>&nbsp;=20
    <P><B><TT>&nbsp;&nbsp;&nbsp;&nbsp; #include =
&lt;sys/types.h&gt;</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp; #include =
&lt;sys/time.h&gt;</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp; main() {</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct =
timeval=20
    tp; struct timezone tzp;</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; struct =
tm=20
    *lt;</TT></B> =
<BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
    long secs1970;</TT></B>=20
    <P><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
    gettimeofday(&amp;tp, &amp;tzp);</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
secs1970=3D=20
    tp.tv_sec;</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lt =3D=20
    localtime(&amp;secs1970);</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
printf(&quot;%d=20
    %d %d %d:%d:%d %d\n&quot;,</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
lt-&gt;tm_wday,=20
    lt-&gt;tm_mon,&nbsp; lt-&gt;tm_mday,</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
lt-&gt;tm_hour,=20
    lt-&gt;tm_min,&nbsp; lt-&gt;tm_sec, lt-&gt;tm_year</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
);</TT></B>=20
    <BR><B><TT>&nbsp;&nbsp;&nbsp;&nbsp; }</TT></B> =
</P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_002F_01BE2C5C.A71B7340--

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