Newsgroups: comp.lang.c
Path: utzoo!utgpu!news-server.csri.toronto.edu!helios.physics.utoronto.ca!aurora.physics.utoronto.ca!neufeld
From: neufeld@aurora.physics.utoronto.ca (Christopher Neufeld)
Subject: Re: Time Info
Message-ID: <1991May26.161643.8944@helios.physics.utoronto.ca>
Sender: news@helios.physics.utoronto.ca (News Administrator)
Nntp-Posting-Host: aurora.physics.utoronto.ca
Organization: University of Toronto Physics/Astronomy/CITA
References: <39@neis.UUCP> <268@bria.UUCP>
Date: Sun, 26 May 1991 16:16:43 GMT

In article <268@bria.UUCP> uunet!bria!mike writes:
>In an article, molnar@neis.UUCP (Christopher Molnar) writes:
>>I am writing a C routine that needs to compare a start time and
>>the current time and have the result in minute.
>
>#include <time.h>
>#include <sys/types.h>
>
>time_t
>deltat(since)
>time_t since;
>{
>time_t now;
>
>	time(&now);
>	return(now - since);
>}
>
   I would rather return the value:  difftime(now, since) / 60.0
On my compiler, 'now-since' doesn't mean minutes or seconds, or
anything else obvious.
   You can also write the function as:
return(difftime(time(NULL),since)/60.0);

which is now so short that it might as well be a #define macro.

#define DELTAT(tnought) (difftime(time(NULL),tnought)/60.0)


>Michael Stefanik
>UUCP: ...!uunet!bria!mike


-- 
 Christopher Neufeld....Just a graduate student  | There no place like $FC58
 neufeld@aurora.physics.utoronto.ca    Ad astra! | They're $FF69-ing my
 cneufeld@{pnet91,pro-cco}.cts.com               | every word! Send for a
 "Don't edit reality for the sake of simplicity" | free $A56E.
