🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #6203

Re: ANSI C date & time library functions.

#6203
From: Henry Spencer
Date: Sat, 10 Feb 1990 22:02
19 lines
1389 bytes
In article <Ccvioy2@cs.psu.edu> flee@shire.cs.psu.edu (Felix Lee) writes:
>Are you allowed to compare time_ts without using difftime()?  Or
>should I write "difftime(now, then) < 0" instead of "now < then"?

There is explicitly no guarantee of the internal representation of time_t.
Since it is an arithmetic type, you can do direct comparisons... but there
is no guarantee that the result will be meaningful.  If you want portable
comparisons, difftime() is indeed the correct method.

>Can time_t be a pointer (converted to an arithmetic if necessary)?
>...This is assuming you don't compare time_t values directly and don't
>try to read or write them.

Unfortunately, there is way too much existing code which assumes that
a time_t can be assigned, passed around, etc.  A pointer is not an
arithmetic type and hence is not a legal time_t type.
-- 
SVR4:  every feature you ever |     Henry Spencer at U of Toronto Zoology
wanted, and plenty you didn't.| uunet!attcan!utzoo!henry henry@zoo.toronto.edu
Technical Details
Message-ID: <1990Feb10.220247.25450@utzoo.uucp>
Path: arc1-ca.pugleaf.net!utzoo!henry
References: <DAVE.90Feb6112502@marvin.moncam.co.uk> <1990Feb9.183316.24925@utzoo.uucp> <Ccvioy2@cs.psu.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: ANSI C date & time library functions.
Message-ID: <1990Feb10.220247.25450@utzoo.uucp>
Organization: U of Toronto Zoology
References: <DAVE.90Feb6112502@marvin.moncam.co.uk> <1990Feb9.183316.24925@utzoo.uucp> <Ccvioy2@cs.psu.edu>
Date: Sat, 10 Feb 90 22:02:47 GMT