Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!nbires!isis!jay From: jay@isis.UUCP (Jay Batson) Newsgroups: net.lang.c Subject: Re: time(2 or 3) Message-ID: <798@isis.UUCP> Date: Wed, 11-Jun-86 11:41:26 EDT Article-I.D.: isis.798 Posted: Wed Jun 11 11:41:26 1986 Date-Received: Sun, 15-Jun-86 02:44:37 EDT References: <337@lll-lcc.UUcp> Reply-To: jay@isis.UUCP (Jay Batson) Organization: University of Denver Math and Computer Science Lines: 49 Keywords: time, localtime Summary: Just because we've figured things out doesn't mean we can't share them In article <337@lll-lcc.UUcp> zingman@lll-lcc.UUcp (Jonathan Zingman) writes: > ... I want to use the >routine localtime, which breaks down a pointer "such as returned by >time(2)." Later in the same section of the manual it says "SEE ALSO ^^^^^^^ I would hope you can find it - I can't imagine you'd have ctime(3) and _not_ have time(2). look again, or in you online man. >time(3)" I can't find time in either of those sections, and my guesses ^^^^^^^ my manual doesn't say this, but then again, I'm still on v7... >at how to call it so far have not worked.... Easy. #include some_fcn(params) sometype params; { long somevar1; struct tm *somevar2; /* or... */ struct tm *somevar2, *localtime(); /* depending on whether or not your already defines localtime or not... */ /* ok, first get ahold of the number of seconds since Jan 1, 1970 */ somevar1 = time(0); /* ok, now pass localtime a pointer to somevar1. localtime will will go about declaring the structure it will use, and fill the structure up with appropriate info - we just want to expect to be returned a pointer to what localtime comes up with */ somevar2 = localtime(&somevar1); /* note &somevar1 passes a pointer */ /* ^^^ pointer recv'g what retd */ /* to what we got from time(2) */ /* ok, now to get at what localtime has prepared for us, here is an example */ printf("The current time is: %2d:%2d:%2d (on a 24 hour clock)\n", somevar2->tm_hour, somevar2->tm_min, somevar2->tm_sec); } /* end some_fcn */ See? Easy. -------- "OK, so now, after it gets dark Lancelot and I will jump out of the rabbit, and take the castle by supr........ oh." Jay Batson {seismo,hplabs}!hao!isis!jay