Mail Archives: cygwin/1998/12/20/20:53:27
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: owner-gnu-win32 AT cygnus DOT com [mailto:owner-gnu-win32 AT cygnus DOT com]On
Behalf Of Dominia
Sent: Sunday, December 20, 1998 11:32 AM
To: gnu-win32 AT cygnus DOT 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
);
}
------=_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. 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> </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> </DIV>
<DIV>
<P><FONT size=3D2>- Brian S.=20
Smith<BR>- PicoDyne Corporation<BR>- =
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> =
owner-gnu-win32 AT cygnus DOT com=20
[mailto:owner-gnu-win32 AT cygnus DOT com]<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:gnu-win32 AT cygnus DOT com">gnu-win32 AT cygnus DOT com</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 "time" 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> <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
"gcc test.c" and then I ran ./a.out and got the results I =
reported=20
above.)</TT></B> <BR> =20
<P><B><TT> #include =
<sys/types.h></TT></B>=20
<BR><B><TT> #include =
<sys/time.h></TT></B>=20
<BR><B><TT> main() {</TT></B>=20
<BR><B><TT> struct =
timeval=20
tp; struct timezone tzp;</TT></B>=20
<BR><B><TT> struct =
tm=20
*lt;</TT></B> =
<BR><B><TT> =20
long secs1970;</TT></B>=20
<P><B><TT> =20
gettimeofday(&tp, &tzp);</TT></B>=20
<BR><B><TT> =
secs1970=3D=20
tp.tv_sec;</TT></B>=20
<BR><B><TT> lt =3D=20
localtime(&secs1970);</TT></B>=20
<BR><B><TT> =
printf("%d=20
%d %d %d:%d:%d %d\n",</TT></B>=20
<BR><B><TT> =
lt->tm_wday,=20
lt->tm_mon, lt->tm_mday,</TT></B>=20
<BR><B><TT> =
lt->tm_hour,=20
lt->tm_min, lt->tm_sec, lt->tm_year</TT></B>=20
<BR><B><TT> =
);</TT></B>=20
<BR><B><TT> }</TT></B> =
</P></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_002F_01BE2C5C.A71B7340--
-
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 -